WO2021037228A1 - 一种***应用的管理方法及装置 - Google Patents

一种***应用的管理方法及装置 Download PDF

Info

Publication number
WO2021037228A1
WO2021037228A1 PCT/CN2020/112213 CN2020112213W WO2021037228A1 WO 2021037228 A1 WO2021037228 A1 WO 2021037228A1 CN 2020112213 W CN2020112213 W CN 2020112213W WO 2021037228 A1 WO2021037228 A1 WO 2021037228A1
Authority
WO
WIPO (PCT)
Prior art keywords
system application
application
resource
period
unified
Prior art date
Application number
PCT/CN2020/112213
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 华为技术有限公司
Publication of WO2021037228A1 publication Critical patent/WO2021037228A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W52/00Power management, e.g. TPC [Transmission Power Control], power saving or power classes
    • H04W52/02Power saving arrangements
    • H04W52/0209Power saving arrangements in terminal devices
    • H04W52/0261Power saving arrangements in terminal devices managing power supply demand, e.g. depending on battery level
    • H04W52/0264Power saving arrangements in terminal devices managing power supply demand, e.g. depending on battery level by selectively disabling software applications
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W52/00Power management, e.g. TPC [Transmission Power Control], power saving or power classes
    • H04W52/02Power saving arrangements
    • H04W52/0209Power saving arrangements in terminal devices
    • H04W52/0261Power saving arrangements in terminal devices managing power supply demand, e.g. depending on battery level
    • H04W52/0267Power saving arrangements in terminal devices managing power supply demand, e.g. depending on battery level by controlling user interface components
    • H04W52/027Power saving arrangements in terminal devices managing power supply demand, e.g. depending on battery level by controlling user interface components by controlling a display operation or backlight unit
    • 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

  • This application relates to the field of terminal technology, and in particular to a method and device for managing system applications.
  • the present application provides a method and device for managing system applications, which are used to reduce the power consumption of the mobile phone and reduce the heat generation of the mobile phone.
  • the embodiments of the present application provide a method for managing system applications, which can be applied to electronic devices such as mobile phones and tablet computers.
  • the method includes: entering the maintenance period, which can include a unified dormant period and a unified active period; during the unified dormant period, freezing system applications that are running in the background; and during the unified active period that appears after the unified dormant period, Unfreeze the system application.
  • freezing the system application includes: suspending some or all of the resources used by the system application.
  • the resources used by the system application include the first resource and/or the second resource; the method further includes: when the system application uses the first resource, recording the resource host of the first resource and the resource host of the first resource.
  • the resource host includes the user identifier UID of the system application and the process name or process identifier PID of the first process of the system application; and/or, when the system application uses the second resource, the resource host of the second resource is recorded, the second resource
  • the resource host includes the package name of the system application and the process name or PID of the second process of the system application.
  • the package name of the system application may be a shared package name
  • the UID may be a shared UID
  • the system application may be further recorded The process name or PID of the process, so that it is convenient to accurately distinguish the resources used by different system applications.
  • the UID of the system application is a shared UID
  • suspend the second resource including: if the package of the system application is named a shared package Name, the second resource is suspended according to the process name or PID of the second process.
  • the resources used by the system applications in the background running state are managed and controlled according to the process names or PIDs of the processes of the system applications, so as to achieve accurate and effective management and control of the resources used by the system applications.
  • entering the maintenance period includes: after activating the management function of the system application, if it is determined to enter the first mode, start the first timer; the first mode includes the screen off mode or the sleep mode; The duration of the timer is greater than or equal to the first duration, and the maintenance period is entered.
  • the first mode may include an off-screen mode or a sleep mode.
  • the electronic device enters the off-screen mode or sleep mode, one or more system applications running on the electronic device enter the background running state.
  • a period of time (such as the first period) can be reserved and then enter the maintenance period, so that Each system application that enters the background running state can execute the corresponding business within this period of time, so as to avoid entering the unified dormant period prematurely and causing the business to fail to execute normally.
  • the electronic device since the electronic device enters the maintenance period to manage and control the resources used by the system application after the electronic device enters the first mode, the power consumption of the electronic device in the first mode can be effectively reduced.
  • entering the maintenance period includes: if the management function of the system application is activated, starting the second timer; if the duration of the second timer is greater than or equal to the fourth duration, entering the maintenance period.
  • a period of time (such as the second duration) can be reserved to enter the maintenance period, that is to say, the maintenance period can be entered regardless of whether the electronic device is in the first mode or the second mode.
  • the resources used by system applications can be managed and controlled, which can effectively reduce the power consumption of electronic devices in the first mode and the second mode.
  • freezing the system application in the background running state includes: detecting that the system application enters the background running state, and starting the third timer corresponding to the system application; if the third timer is timed When the duration of the device is greater than or equal to the fifth duration and is in the unified sleep period, the system application is frozen.
  • the system application before freezing the system application, it further includes: determining that the system application does not have a perceptible service, and the system application is not registered to keep alive.
  • perceivable services can be understood as services that can be heard and seen by the user and can be perceived by the user. Therefore, in order to avoid degrading user experience and ensure the normal execution of perceivable services, the system application Before freezing, it is necessary to ensure that the system application does not have perceivable services; when the system application needs to perform emergency services, it can be registered to keep alive. Therefore, in order to ensure the normal execution of emergency services, it is necessary to ensure that the system application is not registered to keep alive before freezing the system application .
  • the method further includes: determining a unified sleep period according to the sleep period of the system application; wherein the sleep period of the system application is equal to the active period of the system application; and determining the unified active period according to the active period of the system application ; Among them, the active period of the system application is equal to the active duration of the system application.
  • an embodiment of the present application also provides an electronic device.
  • the electronic device includes a display screen, at least one processor and a memory; the memory is used to store one or more computer programs; when the one or more computer programs stored in the memory are executed by the at least one processor,
  • the electronic device can implement the foregoing first aspect and any possible design technical solution of the first aspect.
  • an embodiment of the present application also provides an electronic device, the electronic device includes modules/units that execute the above-mentioned first aspect or any one of the possible design methods of the first aspect; these modules/units can pass Hardware implementation can also be implemented by hardware executing corresponding software.
  • an embodiment of the present application further provides a chip, which is coupled with a memory in an electronic device, and is used to call a computer program stored in the memory and execute the first aspect of the embodiments of the present application and any one of the first aspects thereof.
  • a chip which is coupled with a memory in an electronic device, and is used to call a computer program stored in the memory and execute the first aspect of the embodiments of the present application and any one of the first aspects thereof.
  • an embodiment of the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium includes a computer program.
  • the computer program runs on an electronic device, the electronic device executes the first On the one hand and any possible design technical solutions of the first aspect.
  • a program product in the embodiments of the present application includes instructions that, when the program product runs on an electronic device, cause the electronic device to execute the first aspect of the embodiments of the present application and any one of the first aspects thereof. Possible technical solutions designed.
  • Figure 1a is a schematic diagram of an application icon provided by an embodiment of the application.
  • Figure 1b is an example of the definition in Process.java of the UID of the Android operating system to the system application provided by the embodiment of the application;
  • FIG. 1c is a schematic structural diagram of a mobile phone provided by an embodiment of the application.
  • Figure 2a is a block diagram of the software structure of a mobile phone provided by an embodiment of the application.
  • Figure 2b is a schematic diagram of the functions of the application layer, resource management and control module, application management and control module, and registration callback module provided by an embodiment of the application;
  • Figure 3a is a schematic diagram of the active situation of the system application when the resources used by the system application running in the background are not restricted;
  • FIG. 3b is a schematic diagram of the active situation of the system application after adopting the system application management method provided by the embodiment of the present application;
  • Figure 4a is a schematic diagram of a process of recording a resource host provided by an embodiment of the application.
  • FIG. 4b is an example of resource host and other resource information recorded by the resource management and control module provided by the embodiment of the application;
  • Figure 4c is a schematic diagram of managing and controlling resources used by system applications according to an embodiment of the application.
  • FIG. 5a is a schematic flow diagram corresponding to a method for managing system applications provided in scenario 1 of the embodiment of the application;
  • FIG. 5b is a schematic flow diagram corresponding to another system application management method provided in scenario 1 of the embodiment of the application;
  • FIG. 6a is a schematic flow diagram corresponding to a method for managing system applications provided in scenario 2 of the embodiment of the application;
  • FIG. 6b is a schematic flow diagram corresponding to another system application management method provided in scenario 2 of the embodiment of the application.
  • FIG. 7 is a schematic structural diagram of an electronic device provided by an embodiment of the application.
  • the electronic device can be a device that can install various applications and can display objects provided in the installed applications.
  • the electronic device may include a device capable of realizing data processing functions (such as a processor or an image processor or other processors), and a device capable of displaying a user interface (such as a display screen).
  • the electronic device can be mobile or fixed.
  • the electronic device may be a smart phone, a tablet computer, various types of wearable devices, a vehicle-mounted device, a personal digital assistant (PDA), or other electronic devices that can implement the above-mentioned functions.
  • PDA personal digital assistant
  • OS Operating system
  • Windows system Windows system
  • Android system IOS system
  • IOS IOS system
  • the operating system can be an Android system or an IOS system.
  • the embodiments of this application are mainly introduced by taking the Android system as an example. Those skilled in the art can understand that similar algorithms can also be used in other operating systems.
  • Application can be referred to as an application for short, which is a computer program that can complete one or more specific functions. It may have a visual display interface that can interact with users, such as settings, electronic maps, WeChat, QQ, etc.; or, it may not have a visual display interface and cannot interact with users.
  • applications can be divided into third-party applications and system applications.
  • Third-party applications can be understood as applications installed by users, such as WeChat, Tencent chat software (QQ), WhatsApp Messenger, Line, Kakao Talk, Dingding, etc.
  • system applications can be understood as applications preset by the operating system, such as settings, dialing, and information.
  • the running status of the application in the operating system can be divided into the foreground running status and the background running status.
  • the foreground running state that is, running directly on the display window or interface of the display screen, presents the current interface of the program running, and can interact with the user of the terminal device (ie, the user) through the displayed interface.
  • the background running state means that the display does not show the running interface of the application, but the application continues to provide services in the background. For an application with a visual display interface, it can be switched from the background running state to the foreground running state or from the foreground running state to the background running state at any time; for applications that do not have a visual display interface, its It can be in the background running state, but cannot be switched to the foreground running state.
  • Application icon It is an icon displayed on the desktop for the user to identify the application. For example, as shown in Figure 1a, the camera, settings, etc. are the application icons. The user clicks on the application icon to open the corresponding application.
  • an application with a visual display interface may have a corresponding application icon, while an application without a visual display interface does not have a corresponding application icon.
  • Application identifier It can also be called user identification (UID) or application identifier, which is an identifier assigned by the system during the application installation process. Multiple applications can share an application identifier.
  • UID user identification
  • application identifier an identifier assigned by the system during the application installation process. Multiple applications can share an application identifier.
  • the UID of the third-party application starts from 10000 (ie FIRST_APPLICATION_UID) and ends at 19999 (ie LAST_APPLICATION_UID). You can view FIRST_APPLICATION_UID and LAST_APPLICATION_UID in Process.java.
  • the UID of third-party applications is usually greater than FIRST_APPLICATION_UID
  • the UID of system applications is usually less than FIRST_APPLICATION_UID.
  • Process identification it can be a process identification (PID) or a process name, where PID is an identification that the operating system assigns to the process of the application after the application runs. After the application stops running, the operating system will withdraw the PID, and when the application starts running again, the operating system will reassign a new PID.
  • PID is an identification that the operating system assigns to the process of the application after the application runs. After the application stops running, the operating system will withdraw the PID, and when the application starts running again, the operating system will reassign a new PID.
  • a process identifier uniquely identifies a process.
  • Package name (package name): The package name is mainly used by the system to identify applications, and multiple applications can share a package name.
  • the embodiment of the present application provides a method for managing system applications, and the method can be applied to any electronic device with multiple system applications installed.
  • the electronic device is a mobile phone as an example for introduction.
  • FIG. 1c shows a schematic structural diagram of a mobile phone 100.
  • the mobile phone 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, and a battery 142, Antenna 1, antenna 2, mobile communication module 151, wireless communication module 152, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone interface 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, A display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
  • SIM subscriber identification module
  • the processor 110 may include one or more processing units.
  • the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), and an image signal.
  • AP application processor
  • GPU graphics processing unit
  • ISP image signal processor
  • controller memory
  • video codec digital signal processor
  • DSP digital signal processor
  • baseband processor baseband processor
  • NPU neural-network processing unit
  • the different processing units may be independent devices or integrated in one or more processors.
  • the controller may be the nerve center and command center of the mobile phone 100.
  • the controller can generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
  • a memory may also be provided in the processor 110 to store instructions and data.
  • the memory in the processor 110 is a cache memory.
  • the memory can store instructions or data that the processor 110 has just used or used cyclically. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. Repeated accesses are avoided, the waiting time of the processor 110 is reduced, and the efficiency of the system is improved.
  • the processor 110 may run the software code/module corresponding to the management method of the system application, and execute the corresponding process to freeze the system application in the background running state during the unified sleep period. During the period, the system application will be lifted, and the specific process will be introduced later.
  • the display screen 194 is used to display the display interface of the system application in the foreground running state in the mobile phone 100, such as the display interface of the setting application in the foreground running state.
  • the display screen 194 includes a display panel.
  • the display panel can adopt liquid crystal display (LCD), organic light-emitting diode (OLED), active matrix organic light-emitting diode or active-matrix organic light-emitting diode (active-matrix organic light-emitting diode).
  • the mobile phone 100 may include one or N display screens 194, and N is a positive integer greater than one.
  • the camera 193 is used to capture still images, moving images, or videos.
  • the number of cameras 193 in the mobile phone 100 may be at least two. Take two as an example, one of which is a front camera and the other is a rear camera; taking three as an example, one of which is a front camera and the other two are a rear camera.
  • the internal memory 121 may be used to store computer executable program code, where the executable program code includes instructions.
  • the processor 110 executes various functions and data processing of the mobile phone 100 by running instructions stored in the internal memory 121.
  • the internal memory 121 may include a storage program area and a storage data area. Among them, the storage program area can store the operating system, at least one application program (such as settings, mobile phone housekeeper) required for at least one function, and so on.
  • the data storage area can store data created during the use of the mobile phone 100 and so on.
  • the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.
  • UFS universal flash storage
  • the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and an ambient light sensor 180L, bone conduction sensor 180M, etc.
  • the mobile phone 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. For example, music playback, recording, etc.
  • the mobile phone 100 can receive key 190 input, and generate key signal input related to user settings and function control of the mobile phone 100.
  • the mobile phone 100 can use the motor 191 to generate a vibration notification (such as an incoming call vibration notification).
  • the indicator 192 in the mobile phone 100 can be an indicator light, which can be used to indicate the charging status, power change, and can also be used to indicate messages, missed calls, notifications, and so on.
  • the SIM card interface 195 in the mobile phone 100 is used to connect to the SIM card.
  • the SIM card can be connected to and separated from the mobile phone 100 by inserting into the SIM card interface 195 or pulling out from the SIM card interface 195.
  • the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the mobile phone 100.
  • the mobile phone 100 may include more or fewer components than shown, or combine certain components, or split certain components, or arrange different components.
  • the illustrated components can be implemented in hardware, software, or a combination of software and hardware.
  • FIG. 1c describes the hardware structure of the mobile phone 100.
  • the following takes the Android operating system as an example to introduce the software structure of the mobile phone 100 provided by the embodiment of the present application.
  • Fig. 2a shows a block diagram of the software structure of the mobile phone 100 provided by an embodiment of the present application.
  • the software structure of the mobile phone adopts a layered architecture.
  • the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Communication between layers through software interface.
  • the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.
  • the application layer can include a series of application packages. As shown in Figure 2a, the application layer can include system applications and third-party applications.
  • the system applications can include cameras, settings, skin modules, user interfaces (UI), mobile phone butlers, calls, and short messages.
  • third-party applications can include maps, navigation, music, videos, etc.
  • the application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer.
  • the application framework layer includes some predefined functions.
  • the application framework layer can include window manager, content provider, view system, phone manager, resource manager, notification manager, package management service module, resource management control module, application management control module, registration callback Modules, etc., can also include Wakelock agents, Alarm agents, and broadcast agents (not shown in the figure for the time being).
  • the registration callback module as an example, the embodiment of the present application refers to it as the registration callback module for the convenience of description. In other possible embodiments, it may have other names, which are not specifically limited.
  • the window manager is used to manage window programs.
  • the window manager can obtain the size of the display, determine whether there is a status bar, lock the screen, take a screenshot, etc.
  • the content provider is used to store and retrieve data and make these data accessible to applications.
  • the data may include videos, images, audios, phone calls made and received, browsing history and bookmarks, phone book, etc.
  • the view system includes visual controls, such as controls that display text, controls that display pictures, and so on.
  • the view system can be used to build applications.
  • the display interface can be composed of one or more views.
  • a display interface that includes a short message notification icon may include a view that displays text and a view that displays pictures.
  • the phone manager is used to provide the communication functions of the mobile phone 100, such as the management of the call status (including connecting, hanging up, etc.).
  • the notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages, and it can disappear automatically after a short stay without user interaction.
  • the notification manager is used to notify download completion, message reminders, and so on.
  • the notification manager can also be a notification that appears in the status bar at the top of the system in the form of a chart or a scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, text messages are prompted in the status bar, prompt sounds are emitted, electronic devices vibrate, and indicator lights flash.
  • the package management service module is used to obtain the identity information of the application, such as the package name or UID of the application, when the application is started.
  • the resource management and control module includes a first resource management and control module and a second resource management and control module.
  • the first resource management and control module is used to manage resources based on the application level. For example, the resource host can be recorded according to the package name or UID of the application.
  • the second resource management and control module is used to manage and control resources based on the process level, for example, the resource host can be recorded according to the process name or PID of the process.
  • the application management and control module is used to control the application, such as deciding to freeze the application or deciding to unfreeze the application.
  • the broadcast agent is used to distribute the broadcast to the corresponding receiver after receiving the broadcast from the sender; and, when the resource management and control module notifies the suspension of the broadcast resource of a system application, cache the broadcast sent to the system application , When the resource management and control module notifies the restoration of the broadcast resource of a certain system application, the buffered broadcast of the system application is sent to the system application.
  • the registration callback module is used to receive the dormant period and active period of the system application registration, and notify the application management and control module of the dormant period and active period of the system application, and receive the registration keep-alive request of the system application, and protect the registration of the system application.
  • the activation request is notified to the application management and control module, and after receiving a reminder that the resource usage of a certain system application issued by the application management and control module exceeds the standard, the reminder is forwarded to the system application.
  • the Wakelock agent is used to manage the Wakelock resources of the system application. For example, when the resource management and control module notifies the suspension of the Wakelock resource of a system application, it acts as a proxy for the Wakelock resource of the system application, and the resource management and control module informs the recovery of a certain system application. In case of Wakelock resource, return the agent's Wakelock resource to the system application.
  • the Alarm agent is used to manage the Alarm resources of the system application. For example, when the resource management and control module notifies the suspension of the Alarm resource of a certain system application, it acts as an agent for the Alarm resource of the system application, and the resource management and control module informs the recovery of a certain system application. When the alarm resource is used, the alarm resource of the agent is returned to the system application.
  • Broadcast agent used to manage the broadcast resources of system applications, for example, when the resource management and control module notifies the suspension of the broadcast resources of a certain system application, it acts as an agent of the broadcast resources of the system application, and the resource management and control module notifies the resume of a certain system application. When broadcasting resources, return the agent's broadcasting resources to the system application.
  • the resource management and control module can send a request to use the resource to the resource management and control module.
  • the resource management and control module can record the resource host, where the recorded resource host can include the package name of the system application (or UID) and PID.
  • the process of the system application can also register the dormant period and active period of the system application with the registration callback module.
  • the registration callback module can notify the application management module of the dormant period and active period registered by the system application to facilitate application management and control.
  • the module determines the unified dormant period and the unified active period based on the dormant period and active period registered by one or more system applications.
  • the process of the system application can also register keep-alive with the registration callback module.
  • the registration callback module can notify the application management and control module of the registration keep-alive request of the system application. In this way, during the unified sleep period, the application management and control module can learn about the system application Whether to register keep-alive, if the system application is registered keep-alive, when the system application is frozen, the registered keep-alive resource may not be suspended.
  • the application management and control module determines to freeze a certain system application (or unfreeze a certain system application), it can send the resource suspension instruction (or resource recovery instruction) of the system application to the resource management and control module, and accordingly, the resource management and control module The module can suspend (or resume) the resources used by the system application according to the recorded resource host.
  • the application management and control module can detect the resource usage of the system application in a set period of time according to the set period. If it is determined that the resource usage of the system application exceeds the preset threshold, it can send to the registration callback module that the system application resource usage exceeds the standard The registration callback module forwards the prompt to the system application, so that the system application can perform self-check and repair.
  • the specific method of self-check and repair is not limited by this application.
  • Android Runtime includes core libraries and virtual machines. 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 functions 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 a virtual machine.
  • the virtual machine executes the java files of the application layer and the application 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.
  • the system library can include multiple functional modules. For example: surface manager (surface manager), media library (Media Libraries), three-dimensional graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), etc.
  • the surface manager is used to manage the display subsystem and provides a combination of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of a variety of commonly used audio and video formats, as well as still image files.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to realize 3D graphics drawing, image rendering, synthesis, and layer processing.
  • the 2D graphics engine is a drawing engine for 2D drawing.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer at least includes a display driver, a camera driver, an audio driver, a sensor driver, etc., which are not limited in the embodiment of the present application.
  • the mobile phone 100 can include multiple applications. There can be multiple applications running in the mobile phone 100 at the same time, but usually only one application can run in the foreground. Can run in the background.
  • the system applications in the background running state include system application 1, system application 2, system application 3. More specifically, these system applications can be the setup process, Android OS core service, push process, Mobile phone retrieval process, etc.
  • System application 1, system application 2, and system application 3 can perform periodic services, and then use certain resources periodically.
  • system application 1 needs to perform positioning services periodically, which in turn needs to periodically use global positioning system (global positioning system, GPS) resources.
  • global positioning system global positioning system, GPS
  • Table 1 Examples of the activity period and activity duration of the system application
  • the second row indicates: system application 1 performs business (or activity once) every 5 minutes, and the activity duration is 30 seconds; the third row indicates: application 2 is active every 6 minutes, and the activity duration is 36 seconds; the fourth line means: Application 3 is active every 9 minutes, and the active duration is 30 seconds.
  • the Android operating system does not limit the resources used by system applications in the background, during the period from t0 to t1, system applications 1, system applications 2, and system applications 3 are active seven times, thus As a result, the Android operating system is frequently woken up, resulting in large power consumption.
  • an embodiment of the present application provides a method for managing system applications, which freezes at least one system application running in the background during the unified sleep period, and unfreezes at least one system application during the unified active period, As a result, at least one system application in the background running state can be uniformly active during the unified active period, avoiding frequent activities of multiple system applications at multiple time points, which may cause large power consumption of the terminal device.
  • At least one refers to one or more, and “multiple” refers to two or more.
  • “And/or” describes the association relationship of the associated objects, indicating that there can be three relationships, for example, A and/or B, which can mean: A alone exists, A and B exist at the same time, and B exists alone, where A, B can be singular or plural.
  • the character “/” generally indicates that the associated objects before and after are in an "or” relationship.
  • the following at least one item (a)” or similar expressions refers to any combination of these items, including any combination of a single item (a) or a plurality of items (a).
  • at least one item (a) of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple .
  • ordinal numbers such as "first" and “second” mentioned in the embodiments of this application are used to distinguish multiple objects, and are not used to limit the order, timing, priority, or importance of multiple objects. degree.
  • first application and the second application are only for distinguishing different applications, but do not indicate the difference in content, priority, sending order, or importance of the two applications.
  • the system application management method provided by the embodiment of the present application can be implemented by one of the mobile phones shown in FIG. 1c.
  • One or more physical components and each layer of the software architecture layer shown in FIG. 2a cooperate with each other to achieve.
  • auto-triggered startup refers to the system application being started by itself; other application-triggered startup means that other applications of the electronic device call the system application startup according to the interface; user-triggered startup can mean that the user starts the system application by triggering the application icon, or The user starts the system application by triggering the startup gesture or the quick startup path corresponding to the system application.
  • the touch sensor 180K in the mobile phone receives the user's touch operation
  • the corresponding hardware interrupt is sent to the kernel layer.
  • the kernel layer processes the touch operation into the original input event (including touch coordinates, time stamp of the touch operation, etc.).
  • the original input events are stored in the kernel layer.
  • the application framework layer obtains the original input event from the kernel layer and identifies the control corresponding to the input event.
  • the setting application calls the interface of the application framework layer, starts the setting application, and then drives the display screen by calling the kernel layer Display the interface of the settings application.
  • resources can include, for example, CPU resources, memory resources (or memory resources), network resources, operating system resources, etc.
  • operating system resources can include soft resources (such as Alarm resources, Wakelock resources, broadcast resources) and hard resources (such as Bluetooth resources, sensor resources, GPS resources).
  • the resource management and control module may record the resource host when the process of setting the application uses the resource.
  • the resource management module may record the resource host when the process of setting the application starts to use the resource.
  • An example of the process of recording the resource host is described below in conjunction with Figure 4a.
  • the process of recording the resource host may include:
  • Step 401 The process of setting the application sends a request to use the Alarm resource to the first resource management and control module.
  • the request may include setting the start time for the application to use the Alarm resource.
  • Step 402 After receiving the request, the first resource management and control module records the package name (such as Com.android.settings) or UID (such as 1000) of the setting application as the resource host of the Alarm resource. Exemplarily, the start time when the setting application uses the Alarm resource can also be recorded.
  • the package name such as Com.android.settings
  • UID such as 1000
  • step 403 the first resource management and control module notifies the second resource management and control module of the event that the process of setting the application uses the Alarm resource.
  • Step 404 The second resource management and control module records the PID of the process of setting the application (for example, com.android.setting) as the resource host of the Alarm resource.
  • Step 405 The second resource management and control module feeds back a response to the first resource management and control to notify the first resource management and control module that the PID of the process of setting the application has been recorded as the resource host of the Alarm resource.
  • the first resource management and control module may feed back a response that the request is successful to the process of setting the application.
  • step 401 to step 406 The number of the steps involved in step 401 to step 406 is only a possible example of the execution flow, and does not constitute a limitation on the sequence of each step.
  • the system application can execute the above steps 401 to 406 multiple times. For example, if the system application needs to use the Alarm resource periodically, it can execute the above steps 401 to 406 periodically.
  • the system application can pass the above steps 401 to step 406 when running in the foreground, or can also pass the above steps 401 to step 406 when running in the background, which is not specifically limited.
  • the value of the Alarm resource recorded in the resource management and control module is
  • the resource host can include the package name of the system application, the UID of the system application, and the PID or process name of the process of the system application. Further, the resource management and control module can also record other information of the Alarm resource, such as the start time of the system application using the Alarm resource.
  • the resource host recorded by the resource management and control module includes the PID, which facilitates subsequent management and control of the resources used by the system application according to the PID or process name.
  • PID the resource host recorded by the resource management and control module
  • the description will mainly take the management and control of resources used by system applications according to PID as an example.
  • resources are managed in units of UID or package names.
  • network resources and Wakelock resources are managed in units of UID.
  • Alarm resources, broadcast resources, GPS resources, Bluetooth resources, etc. are managed in units of package names. Controlled for the unit.
  • the package name of the system application may be a shared package name
  • the UID of the system application may be a shared UID, if it is only based on the package name of the system application or the UID of the system application, it may not be able to accurately measure the resources used by the system application. Suspended or resumed.
  • the recorded resource host also includes the PID or process name, so that the package name of the system application is the shared package name and/or the UID of the system application is the shared UID
  • the resources used by the system application can be accurately controlled based on the PID or process name of the process of the system application.
  • the resources controlled by UID such as network resources and Wakelock resources
  • UID resource controlled by UID
  • the resources used by the system application can also be controlled according to the PID or process name
  • the package name such as Alarm resources, broadcast resources
  • the system application can also be used according to the PID or process name.
  • system applications there are many ways to manage and control the resources used by system applications, such as freezing the system application (after freezing the system application, the system application is in a frozen state) or unfreezing the system application (setting the system application in a frozen state). After the application is unfrozen, the system application is active) to control the resources used by the system application.
  • freezing the system application may include restricting the resource used by the system application or suspending the resource used by the system application.
  • the system application in the frozen state is not closed, but its use of resources is restricted.
  • restricting system applications from using resources may include restricting system applications from using all resources or restricting system applications from using some resources.
  • the resources being used by system applications include CPU resources, memory resources, network resources, and operating system resources.
  • Restricting system applications from using all resources can restrict system applications from using CPU resources, memory resources, network resources, and operating system resources, or It can also be described as suspending the CPU resources, memory resources, network resources, and operating system resources used by system applications; restricting the use of some resources by system applications can limit the use of CPU resources, memory resources, and operating system resources by system applications, but it does not limit System applications use network resources, or can also be described as suspending CPU resources, memory resources, and operating system resources used by system applications, but maintaining network resources used by system applications.
  • the application management and control module determines to freeze the system application, it can determine to restrict the system application from using all or part of the resources according to whether the system application needs to perform a preset service. For example, if the application management and control module determines that the system application needs to perform a preset service (assuming that the resources used by the system application to execute the preset service are network resources and Alarm resources), it can suspend the network resources used by the system applications and resources other than the Alarm resources , While maintaining the network resources and Alarm resources used by the system applications; if the application management control module determines that the system does not need to perform the preset services, it can suspend all the resources used by the system applications.
  • the preset task can be set by those skilled in the art according to actual needs.
  • the preset task can be receiving a message.
  • the application management and control module can determine to freeze the system application in a variety of possible situations (such as entering a unified sleep period), see the description in the following text.
  • system application 1 uses system application 1 as an example to describe possible implementations of Alarm resources, Wakelock resources, broadcast resources, and network resources used by system application 1.
  • an application needs to maintain a connection with the application server corresponding to the application so that the application server can send data to the application.
  • Each application and the corresponding application server can only interact with data after they are connected, or each application and the corresponding application server can only interact with data between applications after they are connected.
  • the application server can decide whether it needs to send data to the application according to the status of the application (online, offline), so the application can use the Alarm resource to periodically send heartbeat messages to the application server to indicate that it is online.
  • the heartbeat message is used to describe the application's status. The status is online.
  • the application management control module determines to suspend the Alarm resource used by system application 1, since the Alarm resource is a resource controlled by the package name, the application management control module can determine whether the package name of the system application 1 is a shared package name, and if so, instruct resource management and control The module suspends the Alarm resource used by the system application 1 according to the PID (or package name and PID) of the system application 1. If not, it instructs the resource management and control module to suspend the Alarm resource used by the system application 1 according to the package name of the system application 1.
  • the resource management and control module can notify the Alarm agent to proxy the Alarm resource used by the system application 1 according to the package name and/or PID of the system application 1.
  • the Alarm agent can traverse all the Alarm resources being used according to the package name and/or PID of the system application 1, find the Alarm resource corresponding to the package name and/or PID of the system application 1, and delay the timing of the Alarm in the future. Duration (for example, 1 year), so as to achieve the effect of pausing the Alarm, so that the heartbeat of system application 1 is paused.
  • the alarm agent may be alarmmanagerservice.
  • suspending the alarm resource used by system application 1 refers to suspending the heartbeat of system application 1; in other possible embodiments, suspending the alarm resource used by system application 1 can also refer to
  • the heartbeat of application 1 is unified.
  • a unified heartbeat cycle can be set, so that system application 1 performs heartbeat according to the unified heartbeat cycle.
  • the heartbeat of the system application 1 can be unified according to the package name and/or PID of the system application 1.
  • the difference between the unified heartbeat and the paused heartbeat is: when the heartbeat is paused, the timing of the Alarm is delayed for a preset time (for example, 1 year), so as to achieve the effect of pausing the heartbeat; while for the unified heartbeat, the Alarm can be set.
  • the timing time of is delayed by the eighth duration (the eighth duration can be obtained based on the timing time of the Alarm and the cycle of the unified heartbeat, for example, if the timing time of the Alarm is 1 minute, the cycle of the unified heartbeat is 2 minutes, then the eighth duration It can be 1 minute), so as to achieve the effect of a unified heartbeat.
  • the system application 1 can receive broadcasts sent by other applications in the mobile phone through broadcast resources.
  • the broadcast sender sends a broadcast message, and there may be multiple receivers.
  • the receiver can specify which broadcasts to receive.
  • the sender can also specify which recipients to send to.
  • the receiver After receiving the broadcast, the receiver can be active in the background or update its own status. If you have designated which senders or receivers, after receiving the sender's broadcast, the broadcast agent does not need to query which receiver needs to receive the broadcast one by one, but directly sends it to the designated receiver.
  • the broadcast will be sent to the broadcast agent of the mobile phone through the sender, and the broadcast agent will distribute the broadcast to the corresponding receivers.
  • the receiver has registered in advance which broadcasts need to be received. When the broadcast agent receives these broadcasts, it will automatically distribute these broadcasts to the corresponding applications).
  • the application management and control module determines to suspend the broadcast resource used by the system application 1, since the broadcast resource is a resource controlled according to the package name, the application management control module can determine whether the package name of the system application 1 is a shared package name, and if so, instruct the resource management and control The module suspends the broadcast resource used by the system application 1 according to the PID (or package name and PID) of the system application 1. If not, it instructs the resource management and control module to suspend the broadcast resource used by the system application 1 according to the package name of the system application 1.
  • the resource management and control module can notify the broadcast agent to act on the broadcast agent to be received by the system application 1 according to the package name and/or PID of the system application 1. In this way, after the broadcast agent receives the broadcast to be sent to the system application 1 or the process of the system application 1, the broadcast can be cached first.
  • the broadcast agent agent when the broadcast agent agent the broadcast to be received by the system application 1 according to the package name and/or PID of the system application 1, it can agent all the broadcasts to be received by the system application 1, or it can also be the system application 1
  • the part of the broadcast to be received is proxied, for example, the preset type of broadcast is proxied, and the broadcast of the non-preset type may not be proxied.
  • the preset type can be set by those skilled in the art according to actual needs.
  • the preset type of broadcast may include a broadcast that reminds the battery.
  • Wakelock is a lock mechanism. As long as an application occupies the lock, the CPU cannot enter the sleep state. For example, when the screen of the mobile phone is turned off, some applications can still wake up the screen to prompt the user with a message, that is, the Wakelock mechanism is used.
  • the application management module determines to suspend the Wakelock resource used by the system application 1, since the Wakelock resource is a resource controlled by UID, the application management module can determine whether the UID of the system application 1 is a shared package name, and if so, instruct the resource management and control module to follow The PID (or UID and PID) of the system application 1 suspends the Wakelock resource used by the system application 1. If not, the resource management and control module is instructed to suspend the Wakelock resource used by the system application 1 according to the UID of the system application 1. Correspondingly, the resource management and control module can notify the Wakelock agent to proxy the Wakelock resource used by the system application 1 according to the UID and/or PID.
  • the Wakelock agent can traverse all the Wakelock resources being used according to the UID and/or PID of the system application 1, find the Wakelock resource corresponding to the UID and/or PID of the system application 1, and store it in the cache.
  • the Wakelock agent may be powermanagerservice.
  • the application management and control module determines to suspend the network resources used by the system application 1, since the network resources are resources controlled by UID, the application management and control module can determine whether the UID of the system application 1 is a shared UID, and if so, instruct the resource management and control module to follow the system
  • the PID (or UID and PID) of the application 1 suspends the network resource of the system application 1. If not, the resource management and control module is instructed to suspend the network resource used by the system application 1 according to the UID of the system application 1. Correspondingly, the resource management and control module suspends the network resources used by the system application 1 according to the UID and/or PID.
  • unfreezing the system application may include lifting the restriction on the resource used by the system application or restoring the resource used by the system application, and the system application in the active state can use the resource without restriction.
  • the application management and control module can determine to unfreeze the system application in a variety of possible situations, for example, when entering the unified active period or when another application calls the system application, it can determine to unfreeze the system application, see the description below .
  • system application 1 The following still takes system application 1 as an example to describe possible implementations of recovering Alarm resources, Wakelock resources, broadcast resources, and network resources used by system application 1.
  • the application management control module determines to restore the Alarm resource used by system application 1, since the Alarm resource is a resource controlled by the package name, the application management control module can determine whether the package name of the system application 1 is a shared package name, and if so, instruct the resource management control module Restore the Alarm resource used by the system application 1 according to the PID (or package name and PID) of the system application 1. If not, instruct the resource management and control module to suspend the alarm resource used by the system application 1 according to the package name of the system application 1.
  • the resource management and control module can notify the Alarm agent to restore the Alarm resources used by the system application 1 according to the package name and/or PID of the system application 1. In this way, the Alarm agent can traverse all the delayed Alarms according to the package name and/or PID of the system application 1, find the alarm corresponding to the package name and/or PID of the system application 1, and restore it to the system application 1.
  • the application management control module can determine whether the package name of the system application 1 is a shared package name, and if so, instruct the resource management and control module The broadcast resource used by the system application 1 is restored according to the PID (or package name and PID) of the system application 1. If not, the resource management and control module is instructed to restore the broadcast resource used by the system application 1 according to the package name of the system application 1.
  • the resource management and control module can notify the broadcast agent to restore the broadcast resources used by the system application 1 according to the package name and/or PID of the system application 1. In this way, the broadcast agent can traverse the broadcasts that have been proxied in the cache, find the broadcast corresponding to the package name and/or PID of the system application 1, and send the broadcast to the system application 1.
  • the application management and control module determines whether the UID of system application 1 is a shared package name, and if so, instruct the resource management and control module to follow the system
  • the PID (or UID and PID) of the application 1 restores the Wakelock resource used by the system application 1. If not, the resource management and control module is instructed to suspend the Wakelock resource used by the system application 1 according to the UID of the system application 1.
  • the resource management and control module can notify the Wakelock agent to restore the Wakelock resource used by the system application 1 according to the UID and/or PID. In this way, the Wakelock agent can traverse the proxy Wakelock resource in the cache according to the UID and/or PID of the system application 1, find the Wakelock resource corresponding to the UID and/or PID of the system application 1, and restore it to the system application 1.
  • the application management and control module determines to restore the network resources used by the system application 1, since the network resources are resources controlled by UID, the application management and control module can determine whether the UID of the system application 1 is a shared UID, and if so, instruct the resource management and control module to follow the system application
  • the PID (or UID and PID) of 1 restores the network resources used by the system application 1. If not, the resource management and control module is instructed to restore the network resources used by the system application 1 according to the UID of the system application 1. Correspondingly, the resource management and control module restores the network resources used by the system application 1 according to the UID and/or PID.
  • the duration of the unified sleep period and the duration of the unified active period may be default, for example, they may be set before the mobile phone leaves the factory.
  • the duration of the unified dormant period and the duration of the unified active period may be set by the user. For example, you can add options for setting the duration of the unified sleep period and the duration of the unified active period in the settings application in advance; in this way, when the user needs to set the duration of the unified sleep period and the duration of the unified active period, the settings application can be opened, and then based on Set the corresponding options.
  • the unified sleep period and/or unified active period may be determined according to the business requirements of one or more system applications, where the business requirements of the system applications can be understood as the system applications need to be executed periodically For example, the system application 1 described in the preceding paragraph needs to periodically perform positioning services.
  • the system application can determine the dormant period and the active period according to its own business requirements.
  • the dormant period of the system application can be understood as the period of the system application executing the business, that is, the active period of the system application; the active period of the system application can be understood The length of time required to execute a service for a system application, that is, the active duration of the system application; further, the system application can report the dormant period and active period to the registration callback module (if the system application does not need to perform periodic services, or the system application does not If there is a dormant period and an active period, it may not be reported to the registration callback module), which is sent by the registration callback module to the application management and control module; accordingly, the application management and control module can determine the unified dormancy according to the dormancy and active periods of one or more system applications Period and unified active period.
  • the system application may report the dormant period and the active period to the registration callback module after it is started, or it may report the dormant period and the active period to the registration callback module after a period of startup.
  • the embodiment of this application reports the dormancy period to the system application.
  • the time of the period and the active period is not limited.
  • the application management and control module determines whether the shortest sleep period in the sleep period of each system application is less than the second duration according to the sleep period of one or more system applications, and if not, determines the shortest sleep period It is a unified dormant period, if yes, the second duration is determined as a unified dormant period.
  • the second duration can be set by those skilled in the art according to actual needs and experience, for example, the second duration is 5 minutes.
  • one or more system applications can include system application 1, system application 2, and system application 3.
  • the sleep period of system application 1 can be the activity period of system application 1, which is 5 minutes, and the period of system application 2
  • the dormant period may be the active period of the system application 2, which is 6 minutes
  • the dormant period of the system application 3 may be the active period of the system application 3, which is 9 minutes.
  • the shortest sleep period of system application 1, system application 2, and system application 3 is 5 minutes, and the shortest sleep period is equal to the second duration. Therefore, the shortest sleep period (ie, 5 minutes) can be determined as the unified sleep period.
  • the application management and control module determines whether the longest active period in the sleep period of each system application is greater than or equal to the third duration according to the active period of one or more system applications.
  • the longest active period is determined as the unified active period, and if so, the third duration is determined as the unified active period.
  • the third duration can be set by those skilled in the art according to actual needs and experience, for example, the third duration is 1 minute.
  • one or more system applications may include system application 1, system application 2, and system application 3.
  • the active period of system application 1 may be the active duration of system application 1, which is 30 seconds, and the active period of system application 2
  • the active period may be the active duration of the system application 2, which is 36 seconds
  • the active period of the system application 3 may be the active duration of the system application 3, which is 30 seconds.
  • the longest active period of system application 1, system application 2, and system application 3 is 36 seconds, and the longest active period is less than the third duration (1 minute). Therefore, the longest active period can be determined as the unified active period.
  • the unified dormant period and the unified active period can be updated when certain conditions are met. For example, when a new system application (such as system application 4) reports the dormant period and active period, the dormant period and active period of the system application 1, system application 2, system application 3, and system application 4 can be compared to the unified dormant period. And unified active period to be updated.
  • system application such as system application 4
  • FIG. 5a is a schematic flow diagram corresponding to a management method of a system application provided in scenario 1 of the embodiment of the application
  • FIG. 5b is a schematic flow diagram corresponding to another method of management of a system application provided in the scenario 1 of the embodiment of the application. The description will be given below with reference to Figures 5a and 5b.
  • the method includes:
  • Step 501 Activate the management function of the system application.
  • the function of the system application can be activated by the user's trigger.
  • a button to activate or deactivate the management function of the system application can be added to the setting application in advance; in this way, when the user needs to activate the management function of the system application, he can open the setting application and activate the management function of the system application by triggering the button.
  • the management function of the system application may be activated by default. For example, when the electronic device is turned on, the management function of the system application is activated, and when the electronic device is turned off, the management function of the system application is deactivated.
  • Step 502 If the electronic device enters the first mode, start timer 1.
  • the first mode may include an off-screen mode or a sleep mode.
  • the Android operating system can predefine a timer (such as timer 1).
  • a timer such as timer 1.
  • the system looks for the pre-defined timer 1 and calls timer.setbase( The function systemclock.elapsedrealtime()) clears timer 1 and then starts timer 1 by calling the timer.start() function to start timing.
  • Step 503 If the duration of timer 1 is greater than or equal to the first duration, the maintenance period is entered.
  • the maintenance period may include at least one unified dormant period and at least one unified active period; when the maintenance period includes multiple unified dormant periods and multiple unified active periods, the unified dormant period and unified active period can appear cyclically .
  • the first duration may be set by those skilled in the art according to actual needs and experience, for example, the first duration may be 30 seconds.
  • the unified dormant period may appear first and then the unified active period, or the unified active period may appear first and then the unified dormant period, and the specifics are not limited. In the following, only the unified dormant period appears first and then the unified active period appears as an example for description.
  • the unified sleep period may be any one of the at least one unified sleep period that appears during the maintenance period, and is referred to as unified sleep period 1 for ease of description
  • At least one system application is frozen; in the unified active period (the unified active period can be the unified active period that appears for the first time after the unified dormant period 1, and is called unified active period 1 for ease of description), apply to at least one system Unfreeze.
  • a system application there may be multiple implementation ways to determine whether a system application is in a background running state.
  • the Android operating system will call methods such as onResume to make the activity of the system application 1 in a running state.
  • activity is an application component.
  • the activity includes: running the Resumed state, suspending the Paused state, and stopping the Stopped state; further, if the activity of the system application 1 is in the Resumed state, it means The system application 1 is in the foreground running state, and if the activity of the system application 1 is in the Paused state, it means that the system application 1 is in the background running state.
  • the system application 1 does not have a visual display interface, after the activity of the system application 1 is started, the activity includes: Resumed state and Stopped state; further, if the activity of the system application 1 is in the Resumed state, it means that the system application 1 is in the background Operating status. In this way, it can be determined whether the system application is in the background running state according to the state of the activity of the system application.
  • the aforementioned at least one system application is a system application that is not in a frozen state.
  • the state of the system application can be marked, and then by reading the state identifier of the system application, it can be known whether the system application is in the frozen state.
  • At least one system application includes system application 1.
  • system application 1 meeting the first preset condition can be understood as system application 1 does not have perceivable services, and system application 1 is not registered to keep alive. That is to say, in the unified dormant period 1, it is detected that the system application 1 does not have a perceivable service and is not registered to keep alive, then the system application 1 can be frozen.
  • the system application 1 If it is detected that the system application 1 has a perceivable service or the system application 1 has registered keep-alive (for example, registered keep-alive for 1 minute), the system application 1 will not be frozen temporarily; in this case, the system application 1 can be frozen according to the set period (for example, 30s) ) Detect whether the perceivable service of the system application 1 ends or whether the keep-alive duration is reached, so that after detecting that the perceptible service of the system application 1 ends or reaches the keep-alive duration, the system application 1 is frozen.
  • the specific implementation of freezing the system application can be referred to the relevant description of freezing the system application above, which will not be repeated here.
  • perceivable services can be understood as services that can be heard and seen by the user and can be perceived by the user, such as playing music, downloading files, etc., but it is not limited to this. If the system application 1 has perceivable services, even though the system application 1 has entered the background to run, the user can still perceive that the system application 1 is executing services. In this case, the system application 1 may not be frozen.
  • the system application may need to perform emergency services (or services that cannot be postponed), in this case, if the emergency service of the system application has not been executed when the unified dormant period is entered, at this time, freezing the system application may cause the emergency service Cannot be executed normally.
  • the embodiment of the present application provides a registration keep-alive mechanism to ensure the normal execution of emergency services. For example, if the system application 1 determines that there is an emergency service that needs to be processed, it can register the keep-alive duration according to the length of time the emergency service needs to be processed. Within the keep-alive duration of the system application 1, the system application 1 may not be frozen.
  • the system application when the system application is registered for keep-alive, it may be all resources used by the registered keep-alive system application, or may also be one or more resources used by the registered keep-alive system application, such as registered keep-alive broadcast resources.
  • the system application if the system application is registered as keep-alive during the unified dormancy period 1, the system application will not be frozen during the keep-alive duration of the system application, which can mean that if the system application is in the unified dormancy period, it will not be frozen.
  • period 1 if the system application has registered all the keep-alive resources, the system application will not be frozen during the keep-alive duration of the system application.
  • the system application can be frozen during the keep-alive duration of the system application, but at this time, only the broadcast resources used by the system application 1 are restricted. Resources without restricting the use of broadcast resources by system applications.
  • the system application registration keep-alive can be understood as the system application registration keep-alive all resources.
  • the system application can also be unfrozen.
  • the system application can also be unfrozen.
  • the system application 1 can be determined to be Application 1 is unfrozen; for example, if the system application 1 is in a frozen state, and the system application 1 is restricted from using some resources without restricting the system application 1’s use of broadcast resources (or only some broadcast resources are restricted), then when there are other applications calling the system application 1 Or when the system application 1 needs to receive the broadcast, it can be determined to unfreeze the system application 1.
  • a person skilled in the art can set various possible situations that need to be released according to actual needs, which is not limited in the embodiment of the present application.
  • the system application 1 is in the active state. If the system application 1 is in the active state for a duration greater than or equal to the sixth duration and is still in the unified sleep period, it can be used again Freeze system application 1.
  • the sixth duration can be set by those skilled in the art according to actual needs and experience, and is not specifically limited.
  • the sixth duration can be 6 seconds.
  • the electronic device if it enters the second mode, it can exit the maintenance period, where the second mode may include a bright screen mode.
  • the system application in the frozen state can be unfrozen.
  • the duration of the maintenance period is related to the duration of the electronic device in the first mode. For example, if the electronic device is in the first mode for a longer period of time, the duration of the maintenance period is longer; the electronic device is in the first mode for a shorter period of time , The duration of the maintenance period is also shorter.
  • the above solution is mainly described based on the situation that the maintenance period includes at least one dormant period and at least one active period. In other possible embodiments, the maintenance period may be shorter, for example, the duration of the maintenance period may be less than Or equal to the duration of the unified dormant period. In this case, the above scheme can also be implemented.
  • the embodiments of the present application can also perform statistics on the resource usage of system applications. If it is determined that the amount of resources used by a system application in a preset time period is greater than or equal to a preset threshold, the resource can be issued to the system application. Use over-standard prompts to facilitate self-inspection and repair of the system application.
  • the preset time period can be set by those skilled in the art according to actual needs and experience, and is not specifically limited.
  • the duration of the preset time period can be less than or equal to the duration of the unified active period.
  • the statistical system application uses resources within the preset time period. If the amount of resources used is greater than or equal to If the threshold is preset, a reminder can be sent to the system application.
  • the amount of resources used can be measured from multiple perspectives. For example, taking Wakelock resources as an example, the amount of resources used can be measured from the perspective of the length of time the Wakelock resources are used.
  • the seventh duration which can be a preset duration
  • the amount of resources used is greater than or equal to the preset duration.
  • Set the threshold In other possible embodiments, it can also be measured from other possible angles, which is not specifically limited.
  • the unified dormant period and the unified active period are determined based on the dormant period and the active period registered by at least one system application, then for system applications that have not registered the dormant period and active period with the registration callback module, for ease of description Taking the system application as the system application 5 as an example, the system application 5 is running in the background. Because the system application 5 has not registered the dormant period and active period, it means that the system application may not need to perform periodic services. Therefore, the system application 5 may not be applied to the system.
  • the system application 5 can be managed and controlled in accordance with the management and control method for at least one system application, that is, if the system application 5 is frozen during the unified dormant period; if it is during the unified active period, the system application 5 is frozen. 5 Unfreeze. That is to say, if the unified dormancy period and the unified active period are determined based on the dormant period and the active period reported by the system application 1, the system application 2 and the system application 3, the unified dormant period and the unified active period can only be applied to the system application 1. , System application 2 and system application 3 are controlled, or the system application 1, system application 2, system application 3, and other system applications running in the background can also be controlled based on the unified dormant period and the unified active period.
  • FIG. 3a the system application management method provided by the embodiment of the present application and the prior art (FIG. 3a) in conjunction with FIG. 3b.
  • FIG. 3b assuming that at least one system application described in Figure 5a above includes system application 1, system application 2, and system application 3, it can be seen that during the period from t0 to t1, system application 1, system application 2.
  • the system application 3 is active 7 times, but the Android operating system is only woken up 3 times, which can effectively reduce power consumption.
  • FIG. 6a is a schematic flow diagram corresponding to a management method of a system application provided in scenario 2 of the embodiment of the application
  • FIG. 6b is a schematic flow diagram corresponding to another method of management of a system application provided in the scenario 2 of the embodiment of the application. The description will be given below in conjunction with Figure 6a and Figure 6b.
  • the method includes:
  • Step 601 Activate the management function of the system application.
  • step 601 For the specific implementation of step 601, reference may be made to the related description of step 501 above.
  • Step 602 Start timer 2.
  • the Android operating system can predefine a timer (called timer 2).
  • timer When the management function of the system application is activated, the system searches for the pre-defined timer 2 and calls timer.setbase(systemclock The .elapsedrealtime()) function clears timer 2 and then starts timer 2 by calling the timer.start() function to start timing.
  • step 603 if the duration of timer 2 is greater than or equal to the fourth duration, the maintenance period is entered.
  • the fourth duration may be set by those skilled in the art according to actual needs and experience, for example, the first duration may be 30 seconds.
  • Step 604 It is determined that the running state of a certain system application (for ease of description, taking the system application 1 as an example) in the operating system is the background running state, and then the timer corresponding to the system application 1 (referred to as timer 3) is started.
  • Step 605 When the duration of the timer 3 is greater than or equal to the fifth duration, if it is in the unified sleep period (for example, the unified sleep period 2), freeze the system application 1 during the unified sleep period 2; after the unified sleep period 2 During the first unified active period 2, the system application 1 is released. Understandably, during the time period when the system application 1 is running in the background, the system application 1 can be frozen again in the unified sleep period 3 that appears after the unified active period 2, and it appears for the first time after the unified sleep period 3. During the unified active period 3, the system application 1 is released, and so on.
  • the unified sleep period for example, the unified sleep period 2
  • the fifth duration can be set by those skilled in the art according to actual needs and experience, for example, the fifth duration can be 30 seconds.
  • the duration of the timer 3 is greater than or equal to the fifth duration, if it is in the unified sleep period and the electronic device is in the second mode (such as the bright screen mode), it is determined whether the system application 1 meets the second preset condition , If it meets, the system application 1 will be frozen.
  • the duration of the timer 3 is greater than or equal to the fifth duration, if it is in the unified sleep period and the electronic device is in the first mode (such as the off-screen mode), it is determined whether the system application 1 meets the first preset condition, and if so, Then the system application 1 is frozen.
  • the duration of the timer 3 is greater than or equal to the fifth duration, if it is in the unified active period, the system application 1 is not frozen.
  • system application 1 meets the second preset condition, it can be understood that the system application 1 does not have a perceivable service, the system application 1 is not registered to keep alive, and the system application 1 is not a system application dependent on the application running in the foreground.
  • the system application 1 meeting the first preset condition can refer to the related description in the above scenario 1.
  • the system application 1 is an application program that the foreground application depends on, which means that the foreground application needs to use the data of the system application 1 to execute.
  • the system application 1 is an application that the foreground application depends on.
  • the communication mechanism between the process of the foreground application and the process of the system application 1 includes: (1) There is at least one of socket and binder communication between the process of the system application 1 and the process of the foreground application. (2) There is memory sharing between the process of the system application 1 and the process of the foreground application. (3) The process of the foreground application waits for the process of the system application 1 on the lock resource.
  • the lock resource wait when the lock resource wait is detected, it can be detected whether the lock resource wait is the process of the foreground application, and if so, it traverses to obtain the wait All the background processes on the lock resource, and all the background processes waiting on the lock resource are the background processes on which the process of the foreground application program depends.
  • the system application 1 can be released freeze. Among them, there can be many situations in which it is determined that the system application 1 needs to be unfrozen.
  • the system application 1 is in a frozen state and the system application 1 is restricted from using all resources
  • the system application 1 when the system application 1 is called by other applications, it can be determined that the system application 1 Unfreeze; For example, if the system application 1 is in the frozen state, and the system application 1 is restricted from using part of the resources without restricting the system application 1’s use of broadcast resources (or only part of the broadcast resources), then when another application calls the system application 1 or When the system application 1 needs to receive the broadcast, it can be determined to unfreeze the system application 1.
  • the system application 1 is switched from the background running state to the foreground running state, it can be determined to unfreeze the system application 1.
  • a person skilled in the art can set various possible situations that need to be released according to actual needs, which is not limited in the embodiment of the present application.
  • the maintenance period can be exited.
  • this embodiment of the application can also perform statistics on the resource usage of system application 1. If it is determined that the amount of resources used by system application 1 in a preset period of time is greater than or equal to a preset threshold, it can be sent to the system application 1. Prompt, so as to facilitate the system application 1 to perform self-check and repair.
  • scenario 1 when the electronic device is in the first mode, the resources used by the system applications in the background running state are performed based on the unified sleep period and the unified active period. Management and control; Regardless of whether the electronic device is in the first mode or the second mode in scenario 2, the resources used by the system applications in the background running state can be controlled based on the unified sleep period and the unified active period. In addition to this difference, the two can be cross-referenced.
  • the resource usage of the system applications running in the background is restricted during the unified dormancy period, and the resource usage restrictions of the system applications running in the background are lifted during the unified active period, thereby facilitating the system applications running in the background.
  • Unified activities to avoid frequent waking up of the operating system which may cause serious power consumption of electronic devices.
  • the package name of the system application may be a shared package name
  • the UID may be a shared UID
  • PID which can limit or unrestrict the resources used by the system application based on the PID, and realize effective management and control of the resources used by the system application.
  • the electronic device may include: one or more processors 702, a memory 703, and one or more computer programs 704; Or multiple communication buses 705 are connected.
  • the one or more computer programs 704 are stored in the aforementioned memory 703 and are configured to be executed by the one or more processors 702, and the one or more computer programs 704 include instructions, and the aforementioned instructions can be used for execution. All or part of the steps described in the embodiment shown in the foregoing FIGS. 4a to 6b.
  • the processor 702 may be a central processing unit (CPU) or an application-specific integrated circuit (ASIC), and may be one or more integrated circuits for controlling program execution, and may be Baseband chip, etc.
  • the number of the memory 703 may be one or more, and the memory 703 may be a read-only memory (ROM), a random access memory (RAM), a disk memory, or the like.
  • the electronic device shown in FIG. 7 may be a mobile phone, an ipad, a notebook computer, a smart TV, a wearable device (such as a smart watch, a smart helmet, or a smart bracelet, etc.).
  • a mobile phone its structure can be seen as shown in FIG. 1c.
  • the memory 703 is the internal memory 121.
  • the method provided in the embodiments of the present application is introduced from the perspective of the terminal device (mobile phone 100) as the execution subject.
  • the terminal device may include a hardware structure and/or a software module, and implement the above functions in the form of a hardware structure, a software module, or a hardware structure plus a software module. Whether a certain function of the above-mentioned functions is executed by a hardware structure, a software module, or a hardware structure plus a software module depends on the specific application and design constraint conditions of the technical solution.
  • the term “when” can be interpreted as meaning “if" or “after” or “in response to determining" or “in response to detecting".
  • the phrase “when determining" or “if detected (statement or event)” can be interpreted as meaning “if determined" or “in response to determining" or “when detected (Condition or event stated)” or “in response to detection of (condition or event stated)”.
  • the computer may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • software it can be implemented in the form of a computer program product in whole or in part.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the computer instructions may be transmitted from a website, computer, server, or data center.
  • 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 usable medium may be a magnetic medium, (for example, a floppy disk, a hard disk, and a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state hard disk).

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Human Computer Interaction (AREA)
  • Telephone Function (AREA)
  • Stored Programmes (AREA)

Abstract

本申请涉及功耗领域,公开了一种***应用的管理方法及装置。其中方法包括:进入维护期,维护期可以包括统一休眠期和统一活跃期;在统一休眠期内,对处于后台运行状态的***应用进行冻结;在统一休眠期之后出现的统一活跃期内,对***应用解除冻结,从而便于处于后台运行状态的一个或多个***应用统一活动,有效减少电子设备的电量消耗以减轻电子设备的发热现象。

Description

一种***应用的管理方法及装置
相关申请的交叉引用
本申请要求在2019年08月28日提交中国专利局、申请号为201910804027.9、申请名称为“一种***应用的管理方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及终端技术领域,尤其涉及一种***应用的管理方法及装置。
背景技术
随着互联网的深度发展,越来越多的行业加入到互联网浪潮中,产生了无数基于互联网的应用,提供了基于文字、图片、视频、游戏、大数据服务等等的娱乐活动。为此人们对终端性能的要求也在不断提高,虽然现在手机的配置以及软件优化已经发展到不错的阶段,但随着应用的不断发展,手机上应用的种类和数量也越来越多。
当前的手机可以同时打开很多个应用,但通常只有一个应用可以在前台运行,其他开启的应用只能在后台运行。用户在打开新的应用时,很少会主动结束其它在后台运行的应用,因此在不知不觉中可能会打开很多的应用,从而会增加手机的处理负荷和电量消耗并导致手机发热,影响用户体验。
发明内容
有鉴于此,本申请提供了一种***应用的管理方法及装置,用以减少手机电量消耗以减轻手机发热现象。
第一方面,本申请实施例提供一种***应用的管理方法,该方法可以应用于诸如手机、平板电脑等电子设备。该方法包括:进入维护期,维护期可以包括统一休眠期和统一活跃期;在统一休眠期内,对处于后台运行状态的***应用进行冻结;在统一休眠期之后出现的统一活跃期内,对***应用解除冻结。
本申请实施例中,通过在维护期内设置统一休眠期和统一活跃期,并在统一休眠期内对***应进行冻结,以及在统一活跃期对***应用解除,从而便于处于后台运行状态的***应用统一活动,避免频繁唤醒操作***而导致电子设备的电量消耗较为严重。
在一种可能的设计中,对***应用进行冻结,包括:挂起***应用所使用的部分或全部资源。
在一种可能的设计中,***应用所使用的资源包括第一资源和/或第二资源;方法还包括:在***应用使用第一资源时,记录第一资源的资源宿主,第一资源的资源宿主包括***应用的用户标识符UID和***应用的第一进程的进程名或进程标识符PID;和/或,在***应用使用第二资源时,记录第二资源的资源宿主,第二资源的资源宿主包括***应用的包名和***应用的第二进程的进程名或PID。
本申请实施例中,考虑到***应用的包名可能为共享包名,UID可能为共享UID,因 此在记录资源宿主时,除记录***应用的包名或UID之外,还可以进一步记录***应用的进程的进程名或PID,从而便于准确区分不同***应用所使用的资源。
在一种可能的设计中,若***应用的UID为共享UID,则根据第一进程的进程名或PID挂起第一资源;挂起第二资源,包括:若***应用的包名为共享包名,则根据第二进程的进程名或PID挂起第二资源。
本申请实施例中,根据***应用的进程的进程名或PID,对处于后台运行状态的***应用所使用的资源进行管控,从而能够实现对***应用所使用的资源进行准确有效的管控。
在一种可能的设计中,进入维护期,包括:激活***应用的管理功能后,若确定进入第一模式,则启动第一计时器;第一模式包括灭屏模式或休眠模式;若第一计时器的时长大于或等于第一时长,则进入维护期。
本申请实施例中,第一模式可以包括灭屏模式或休眠模式。当电子设备进入灭屏模式或休眠模式时,电子设备上运行的一个或多个***应用均进入后台运行状态,此时,可以预留一段时间(比如第一时长)再进入维护期,从而使得各个进入后台运行状态的***应用能够在该段时间内执行相应的业务,避免过早进入统一休眠期而导致业务无法正常执行。且由于是在电子设备进入第一模式后,进入维护期对***应用所使用的资源进行管控,从而能够有效降低电子设备在第一模式下的电量消耗。
在一种可能的设计中,进入维护期,包括:若激活***应用的管理功能,则启动第二计时器;若第二计时器的时长大于或等于第四时长,则进入维护期。
本申请实施例中,激活***应用的管理功能后,可以预留一段时间(比如第二时长)即进入维护期,也就是说,不论电子设备处于第一模式或第二模式,均可以进入维护期对***应用所使用的资源进行管控,从而能够有效降低电子设备在第一模式和第二模式下的电量消耗。
在一种可能的设计中,在统一休眠期内,对处于后台运行状态的***应用进行冻结,包括:检测到***应用进入后台运行状态,启动***应用对应的第三计时器;若第三计时器的时长大于或等于第五时长时处于统一休眠期内,则对***应用进行冻结。
在一种可能的设计中,对***应用进行冻结之前,还包括:确定***应用不具有可感知业务,且***应用未注册保活。
本申请实施例中,可感知业务可以理解为可以被用户听到、看到等可被用户感知到的业务,因此,为避免降低用户体验,保证可感知业务的正常执行,在对***应用进行冻结之前需要确保***应用不具有可感知业务;当***应用需要执行紧急业务时可以注册保活,因此,为保证紧急业务的正常执行,在对***应用进行冻结之前需要确保***应用未注册保活。
在一种可能的设计中,该方法还包括:根据***应用的休眠期,确定统一休眠期;其中,***应用的休眠期等于***应用的活动周期;根据***应用的活跃期,确定统一活跃期;其中,***应用的活跃期等于***应用的活动时长。
第二方面,本申请实施例还提供一种电子设备。该电子设备包括显示屏,至少一个处理器和存储器;所述存储器用于存储一个或多个计算机程序;当所述存储器存储的一个或多个计算机程序被所述至少一个处理器执行时,使得所述电子设备能够实现上述第一方面及其第一方面任一可能设计的技术方案。
第三方面,本申请实施例还提供了一种电子设备,所述电子设备包括执行上述第一方 面或者第一方面的任意一种可能的设计的方法的模块/单元;这些模块/单元可以通过硬件实现,也可以通过硬件执行相应的软件实现。
第四方面,本申请实施例还提供一种芯片,所述芯片与电子设备中的存储器耦合,用于调用存储器中存储的计算机程序并执行本申请实施例第一方面及其第一方面任一可能设计的技术方案;本申请实施例中“耦合”是指两个部件彼此直接或间接地结合。
第五方面,本申请实施例还提供一种计算机可读存储介质,所述计算机可读存储介质包括计算机程序,当计算机程序在电子设备上运行时,使得所述电子设备执行本申请实施例第一方面及其第一方面任一可能设计的技术方案。
第六方面,本申请实施例的中一种程序产品,包括指令,当所述程序产品在电子设备上运行时,使得所述电子设备执行本申请实施例第一方面及其第一方面任一可能设计的技术方案。
附图说明
图1a为本申请实施例提供的应用图标示意图;
图1b为本申请实施例提供的Android操作***对***应用的UID在Process.java中的定义示例;
图1c为本申请实施例提供的手机的结构示意图;
图2a为本申请实施例提供的手机的软件结构框图;
图2b为本申请实施例提供的应用程序层、资源管控模块、应用管控模块、注册回调模块的功能示意;
图3a为对后台运行的***应用所使用的资源不做限制时***应用的活跃情形示意图;
图3b为采用本申请实施例提供的***应用的管理方法后***应用的活跃情形示意图;
图4a为本申请实施例提供的记录资源宿主的过程示意图;
图4b为本申请实施例提供的资源管控模块所记录的资源宿主及资源的其它信息示例;
图4c为本申请实施例提供的对***应用所使用的资源进行管控示意图;
图5a为本申请实施例场景1提供的一种***应用的管理方法所对应的流程示意图;
图5b为本申请实施例场景1提供的又一种***应用的管理方法所对应的流程示意图;
图6a为本申请实施例场景2提供的一种***应用的管理方法所对应的流程示意图;
图6b为本申请实施例场景2提供的又一种***应用的管理方法所对应的流程示意图;
图7为本申请实施例提供的电子设备的结构示意图。
具体实施方式
首先,对本申请实施例涉及的部分用语进行解释说明。
(1)电子设备:可以为安装各类应用程序,并且能够将已安装的应用程序中提供的对象进行显示的设备。示例性地,该电子设备可以包含能够实现数据处理功能的器件(比如处理器或图像处理器或其他处理器),以及能够显示用户界面的器件(比如显示屏)。该电子设备可以是移动的,也可以是固定的。例如,电子设备可以为智能手机、平板电脑、各类可穿戴设备、车载设备、个人数字助理(personal digital assistant,PDA)或其它能够实现上述功能的电子设备等。
(2)操作***(operating system,OS):是运行在电子设备上的最基本的***软件,例如windows***、Android***、IOS***。以智能手机为例,操作***可以是Android***或IOS***。本申请实施例主要以Android***为例进行介绍。本领域技术人员可以理解,其它操作***中,也可以采用类似的算法实现。
(3)应用程序(application,APP):可以简称为应用,为能够完成某项或多项特定功能的计算机程序。它可以具有可视的显示界面,能与用户进行交互,比如设置、电子地图、微信、QQ等;或者,也可以不具有可视的显示界面,不能与用户进行交互。示例性地,应用可以划分为第三方应用和***应用,其中,第三方应用可以理解为用户安装的应用,比如微信、腾讯聊天软件(QQ)、WhatsApp Messenger、连我(Line)、Kakao Talk、钉钉等;***应用可以理解为操作***预置的应用,比如设置、拨号、信息等。
(4)运行状态:应用在操作***中的运行状态可以分为前台运行状态和后台运行状态。前台运行状态,即直接在显示屏的显示窗口或界面上运行,呈现出程序运行的当前界面,可以和终端设备的使用者(即用户)通过显示的界面进行互动。后台运行状态,是指显示屏不呈现应用的运行界面,但该应用在后台继续提供服务。对于具有可视的显示界面的应用来说,其可以随时从后台运行状态切换成前台运行状态,或者从前台运行状态切换为后台运行状态;对于不具有可视的显示界面的应用来说,其可以处于后台运行状态,而无法切换到前台运行状态。
(5)应用图标:为显示在桌面上供用户识别应用的图标,比如如图1a所示,相机、设置等即为应用图标,用户点击应用图标,就可以打开相应的应用。通常情况下,具有可视的显示界面的应用可以具有对应的应用图标,而不具有可视的显示界面的应用不具有对应的应用图标。
(6)应用标识符:也可以称为用户标识符(user identification,UID)或应用标识,是应用安装过程中***为其分配的标识。多个应用可以共享一个应用标识符。示例性地,在Android***中,第三方应用的UID是从10000(即FIRST_APPLICATION_UID)开始,到19999(即LAST_APPLICATION_UID)结束,可以在Process.java中查看到FIRST_APPLICATION_UID和LAST_APPLICATION_UID。其中,第三方应用的UID通常大于FIRST_APPLICATION_UID,而***应用的UID通常小于FIRST_APPLICATION_UID,也存在一些UID大于FIRST_APPLICATION_UID的***应用,参见图1b,示意出了Android操作***对***应用的UID在Process.java中的定义。
进程标识:可以为进程标识符(process identification,PID)或进程名,其中,PID是在应用运行后,操作***为应用的进程分配的身份标识。在应用停止运行后,操作***会将PID收回,当应用程序再次开始运行时,操作***将重新分配新的PID。一个进程标识符唯一标识一个进程。
包名(package name):包名主要用于***识别应用程序,多个应用程序可以共享一个包名。
本申请实施例提供一种***应用的管理方法,该方法可以适用于任何安装有多个***应用的电子设备。以下实施例以电子设备是手机为例进行介绍。示例性地,图1c示出了一种手机100的结构示意图。
如图1c所示,手机100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141, 电池142,天线1,天线2,移动通信模块151,无线通信模块152,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。
其中,处理器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可以运行***应用的管理方法所对应的软件代码/模块,执行相应的流程,以在统一休眠期内对处于后台运行状态的***应用进行冻结,在统一活跃期内对***应用解除冻结,具体的流程将在后文介绍。
显示屏194用于显示手机100中的处于前台运行状态的***应用的显示界面,比如处于前台运行状态的设置应用的显示界面等,当***应用由前台运行状态切换为后台运行状态时,将不再在显示屏上显示。显示屏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的正整数。
摄像头193用于捕获静态图像、动态图像或视频。在本申请实施例中,手机100中摄像头193的数量可以是至少两个。以两个为例,其一个是前置摄像头,另一个是后置摄像头;以三个为例,其中一个是前置摄像头,另外两个是后置摄像头。
内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。处理器110通过运行存储在内部存储器121的指令,从而执行手机100的各种功能以及数据处理。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作***,至少一个功能所需的应用程序(比如设置、手机管家)等。存储数据区可存储手机100使用过程中所创建的数据等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。
传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。
另外,手机100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。手机100可以接收按键190输入,产生与手机100的用户设置以及功能控制有关的键信号输入。手机100可以利用马达191产生振动提示(比如来电振动提示)。手机100中的指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。手机100中的SIM卡接口195用于连接SIM卡。SIM卡可以通过***SIM卡接口195,或从SIM卡接口195拔出,实现和手机100的接触和分离。
可以理解的是,本发明实施例示意的结构并不构成对手机100的具体限定。在本申请另一些实施例中,手机100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
上述图1c对手机100的硬件结构进行了描述,以下以安卓(Android)操作***为例,介绍本申请实施例提供的手机100的软件结构。
图2a示出了本申请实施例提供的手机100的软件结构框图。如图2a所示,手机的软件结构采用分层式架构。分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android***分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)和***库,以及内核层。
应用程序层可以包括一系列应用程序包。如图2a所示,应用程序层可以包括***应用程序和第三方应用程序,其中,***应用程序可以包括相机、设置、皮肤模块、用户界面(user interface,UI)、手机管家、通话、短信息等,第三方应用程序可以包括地图,导航,音乐,视频等。
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。如图2a所示,应用程序框架层可以包括窗口管理器,内容提供器,视图***,电话管理器,资源管理器,通知管理器、包管理服务模块、资源管控模块、应用管控模块、注册回调模块等,还可以包括Wakelock代理、Alarm代理、广播代理(暂未在图中示意)。其中,以注册回调模块为例,本申请实施例是为了便于描述将其称为注册回调模块,在其它可能的实施例中,还可以有其它名称,具体不做限定。
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。视图***包括可视控件,例如显示文字的控件,显示图片的控件等。
视图***可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。电话管理器用于提供手机100的通信功能,例如通话状态的管理(包括接通,挂断等)。通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在***顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息, 发出提示音,电子设备振动,指示灯闪烁等。
包管理服务模块,用于在应用启动时,获取应用的身份信息,例如应用的包名或UID等。
资源管控模块包括第一资源管控模块和第二资源管控模块,其中,第一资源管控模块,用于基于应用级别对资源进行管控,比如可以按照应用的包名或UID记录资源宿主。第二资源管控模块,用于基于进程级别对资源进行管控,比如可以按照进程的进程名或PID记录资源宿主。
应用管控模块,用于对应用进行管控,比如决定对应用进行冻结或者决定对应用解除冻结。广播代理,用于在接收到发送方的广播后,将该广播分发给相应的接收方;以及,在资源管控模块通知挂起某一***应用的广播资源时,缓存发送给该***应用的广播,在资源管控模块通知恢复某一***应用的广播资源时,将缓存的该***应用的广播发送给该***应用。
注册回调模块,用于接收***应用注册的休眠期和活跃期,并将***应用的休眠期和活跃期通知给应用管控模块,以及接收***应用的注册保活请求,并将***应用的注册保活请求通知给应用管控模块,以及在接收到应用管控模块发出的某一***应用的资源使用超标提示后,将该提示转发给该***应用。
Wakelock代理,用于对***应用的Wakelock资源进行管理,比如在资源管控模块通知挂起某一***应用的Wakelock资源时,代理该***应用的Wakelock资源,在资源管控模块通知恢复某一***应用的Wakelock资源时,将代理的Wakelock资源还给该***应用。
Alarm代理,用于对***应用的Alarm资源进行管理,比如在资源管控模块通知挂起某一***应用的Alarm资源时,代理该***应用的Alarm资源,在资源管控模块通知恢复某一***应用的Alarm资源时,将代理的Alarm资源还给该***应用。
广播代理,用于对***应用的广播资源进行管理,比如在资源管控模块通知挂起某一***应用的广播资源时,代理该***应用的广播资源,在资源管控模块通知恢复某一***应用的广播资源时,将代理的广播资源还给该***应用。
为便于清晰描述应用程序层、资源管控模块、应用管控模块、注册回调模块的功能,下面结合图2b进一步介绍。如图2b所示:(1)***应用的进程可以向资源管控模块发送使用资源的请求,相应地,资源管控模块可以记录资源宿主,其中,记录的资源宿主可以包括***应用的包名(或UID)和PID。(2)***应用的进程还可以向注册回调模块注册***应用的休眠期和活跃期,相应地,注册回调模块可以将***应用注册的休眠期和活跃期通知给应用管控模块,以便于应用管控模块基于一个或多个***应用注册的休眠期和活跃期确定统一休眠期和统一活跃期。(3)***应用的进程还可以向注册回调模块注册保活,注册回调模块可以将***应用的注册保活请求通知给应用管控模块,如此,在统一休眠期内,应用管控模块可以获知***应用是否注册保活,若***应用注册保活,则在对***应用进行冻结时,可以不挂起注册保活的资源。(4)应用管控模块若确定冻结某一***应用(或对某一***应用解除冻结),则可以向资源管控模块发出***应用的资源挂起指示(或资源恢复指示),相应地,资源管控模块可以根据记录的资源宿主挂起(或恢复)***应用所使用的资源。(5)应用管控模块可以按照设定周期检测***应用在设定时间段内的资源使用状况,若确定***应用的资源使用超过预设阈值,则可以向注册回调模块发送***应用资源使用超标的提示,进而由注册回调模块将该提示转发给***应用,以便于***应 用进行自检和修复,具体自检和修复的方式本申请不做限定。
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绘图的绘图引擎。
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动等,本申请实施例对此不做任何限制。
以图1c和图2a所示的手机100为例,手机100中可以包括多个应用,手机100中可以同时有多个应用在运行,但通常只有一个应用可以在前台运行,其他开启的应用只能在后台运行。
目前,Android操作***对于在后台运行的***应用所使用的资源不做限制,因此,当在后台运行多个***应用时,会导致终端设备耗电过快、发热严重。举个例子,参见图3a所示,处于后台运行状态的***应用包括***应用1、***应用2、***应用3,更具体的,这些***应用可以是设置进程,Android OS核心服务、push进程、手机找回进程等。***应用1、***应用2和***应用3可以执行周期性业务,进而会周期性使用某些资源,比如***应用1需要周期性执行定位业务,进而需要周期性使用全球定位***(global positioning system,GPS)资源。本申请实施例中,***应用执行业务或者使用资源,可以理解为***应用在活动;***应用执行业务的时长或者使用资源的时长,可以理解为***应用的活动时长。
参见表1所示,为***应用的活动周期和活动时长示例。
表1:***应用的活动周期和活动时长示例
***应用 活动周期(单位为分钟) 活动时长(单位为分钟)
***应用1 5 0.5
***应用2 6 0.6
***应用3 9 0.5
表1中,第二行表示:***应用1每隔5分钟执行一次业务(或者说活动一次),活动时长为30秒;第三行表示:应用程序2每隔6分钟活动一次,活动时长为36秒;第四行表示:应用程序3每隔9分钟活跃一次,活动时长为30秒。
此种情况下,由于Android操作***对***应用在后台所使用的资源不做限定,因此,在t0至t1这段时间内,***应用1、***应用2、***应用3共活动七次,从而使得Android 操作***被频繁唤醒,导致电量消耗较大。
基于此,本申请实施例提供一种***应用的管理方法,在统一休眠期内,对处于后台运行状态的至少一个***应用进行冻结,以及在统一活跃期内,对至少一个***应用解除冻结,从而使得处于后台运行状态的至少一个***应用可以在统一活跃期内统一活动,避免多个***应用在多个时间点频繁活动而导致终端设备的电量消耗较大。
下述实施例中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。“以下至少一项(个)”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b,或c中的至少一项(个),可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中a,b,c可以是单个,也可以是多个。
以及,除非有特别说明,本申请实施例提及“第一”、“第二”等序数词是用于对多个对象进行区分,不用于限定多个对象的顺序、时序、优先级或者重要程度。例如,第一应用和第二应用,只是为了区分不同的应用,而并不是表示这两种应用的内容、优先级、发送顺序或者重要程度等的不同。
示例性地,基于图1c示出的手机的硬件结构图和图2a示出的手机的软件结构图,本申请实施例提供的***应用的管理方法,可以由图1c所示的手机中的一种或多种物理元器件以及图2a所示的软件架构层的各层之间的相互配合来实现。
下面对本申请实施例涉及的相关技术特征进行介绍。
一,***应用使用资源
本申请实施例中,触发***应用启动(或者说打开***应用)的方式可以有多种,比如可以是自动触发启动,也可以是由其它应用触发启动,还可以是用户触发启动。其中,自动触发启动是指***应用自行启动;其它应用触发启动是指由电子设备的其它应用根据接口调用该***应用启动;用户触发启动可以是指用户通过触发应用图标来启动***应用,也可以是用户通过触发***应用对应的启动手势或者快速启动路径来启动***应用。
以用户触发***应用(比如设置应用)启动为例,结合图1c和图2a来说,当手机中的触摸传感器180K接收到用户的触摸操作,相应的硬件中断被发给内核层。内核层将触摸操作加工成原始输入事件(包括触摸坐标,触摸操作的时间戳等信息)。原始输入事件被存储在内核层。应用程序框架层从内核层获取原始输入事件,识别该输入事件所对应的控件。以该触摸操作是触摸单击操作,且该单击操作所对应的控件为设置的应用图标的控件为例,设置应用调用应用框架层的接口,启动设置应用,进而通过调用内核层驱动显示屏显示设置应用的界面。
进一步地,设置应用启动后,设置应用的进程可以使用资源。其中,资源可以包括比如CPU资源、存储器资源(或者说内存资源)、网络资源、操作***的资源等,操作***的资源可以包括软资源(比如Alarm资源、Wakelock资源、广播资源)和硬资源(比如蓝牙资源、传感器资源、GPS资源)。
本申请实施例中,资源管控模块可以在设置应用的进程使用资源时记录资源宿主,比如资源管控模块可以在设置应用的进程开始使用资源时记录资源宿主。下面结合图4a描述记录资源宿主的过程示例。
示例性地,以设置应用使用Alarm资源为例,参见图4a所示,记录资源宿主的过程可以包括:
步骤401,设置应用的进程向第一资源管控模块发送使用Alarm资源的请求。示例性地,该请求中可以包括设置应用使用Alarm资源的开始时间。
步骤402,第一资源管控模块接收到该请求后,记录设置应用的包名(比如Com.android.settings)或UID(比如1000)作为Alarm资源的资源宿主。示例性地,还可以记录设置应用使用Alarm资源的开始时间。
步骤403,第一资源管控模块将设置应用的进程使用Alarm资源这一事件通知给第二资源管控模块。
步骤404,第二资源管控模块记录设置应用的进程的PID(比如com.android.setting)作为Alarm资源的资源宿主。
步骤405,第二资源管控模块向第一资源管控反馈响应,以通知第一资源管控模块已记录设置应用的进程的PID作为Alarm资源的资源宿主。
步骤406,第一资源管控模块接收到第一资源管控反馈的响应后,可以向设置应用的进程反馈请求成功的响应。
示例性地:(1)上述是以设置应用的进程请求成功为例进行描述的,在一些可能的场景下,设置应用的进程也可能请求失败,此种情形下,第一资源管控模块可以向设置应用的进程反馈请求失败的响应。(2)步骤401至步骤406中的所涉及的步骤编号仅为执行流程的一种可能的示例,并不构成对各个步骤先后顺序的限定。(3)本申请实施例中,***应用可以通过多次执行上述步骤401至步骤406,比如***应用需要周期性使用Alarm资源,则可以周期性执行上述步骤401至步骤406。(4)***应用可以在前台运行时通过上述步骤401至步骤406,或者,也可以在后台运行时通过上述步骤401至步骤406,具体不做限定。
通过上述所描述的过程可知,本申请实施例中,参见图4b所示,当***应用的进程向资源管控模块发送使用资源(比如Alarm资源)的请求后,资源管控模块中记录的Alarm资源的资源宿主可以包括***应用的包名、***应用的UID、***应用的进程的PID或进程名,进一步地,资源管控模块还可以记录Alarm资源的其它信息,比如***应用使用Alarm资源的开始时间。本申请实施例中,由于在***应用使用资源时,资源管控模块记录的资源宿主包括PID,从而便于后续按照PID或进程名对***应用所使用的资源进行管控。为便于说明,后文中当涉及到按照PID或进程名对***应用所使用的资源进行管控时,将主要以按照PID对***应用所使用的资源进行管控为例进行描述。
通常情况下,资源是以UID或包名为单位进行管控的,例如,网络资源、Wakelock资源等是以UID为单位进行管控的,Alarm资源、广播资源、GPS资源、蓝牙资源等是以包名为单位进行管控的。然而,考虑到***应用的包名可能是共享包名,***应用的UID可能是共享UID,若仅是基于***应用的包名或***应用的UID可能无法准确地对***应用所使用的资源进行挂起或恢复,因此,本申请实施例中在***应用使用资源时,记录的资源宿主还包括PID或进程名,从而在***应用的包名是共享包名和/或***应用的UID是共享UID时,可以基于***应用的进程的PID或进程名准确对***应用所使用的资源进行管控。也就是说,参见图4c所示,针对于一些按照UID管控的资源(比如网络资源、Wakelock资源),当***应用的UID为独立UID时,可以仍按照UID对其进行管控,而 当***应用的UID为共享UID时,本申请实施例中还可以按照PID或进程名对***应用所使用的资源进行管控;针对于一些按照包名管控的资源(比如Alarm资源、广播资源),当***应用的包名为独立包名时,可以仍按照包名对其进行管控,而当***应用的包名为共享包名时,本申请实施例中还可以按照PID或进程名对***应用所使用的资源进行管控。
本申请实施例中,对***应用所使用的资源进行管控的实现方式可以有多种,比如可以通过冻结***应用(冻结***应用后,***应用处于冻结状态)或者对***应用解除冻结(对***应用解除冻结后,***应用处于活跃状态)来对***应用所使用的资源进行管控。
二,冻结***应用
本申请实施例中,冻结***应用可以包括限制***应用使用资源或者说挂起***应用所使用的资源,处于冻结状态的***应用并没有被关闭,但限制了其对资源的使用。
示例性地,限制***应用使用资源,可以包括限制***应用使用全部资源或者限制***应用使用部分资源。比如,***应用正在使用的资源包括CPU资源、存储器资源、网络资源和操作***的资源,限制***应用使用全部资源可以为限制***应用使用CPU资源、存储器资源、网络资源和操作***的资源,或者也可以描述为挂起***应用使用的CPU资源、存储器资源、网络资源和操作***的资源;限制***应用使用部分资源可以为限制***应用使用CPU资源、存储器资源和操作***的资源,但不限制***应用使用网络资源,或者也可以描述为挂起***应用使用的CPU资源、存储器资源和操作***的资源,但保持***应用使用的网络资源。
本申请实施例中,应用管控模块若确定冻结***应用,则可以根据***应用是否需要执行预设业务,来确定限制***应用使用全部或部分资源。比如,应用管控模块若确定***应用需要执行预设业务(假设***应用执行预设业务需要使用的资源为网络资源和Alarm资源),则可以挂起***应用使用的网络资源和Alarm资源以外的资源,而保持***应用使用的网络资源和Alarm资源;应用管控模块若确定***该应用不需要执行预设业务,则可以挂起***应用使用的全部资源。其中,预设任务可以由本领域技术人员根据实际需要来设置,比如预设任务可以为接收消息。应用管控模块可以在多种可能的情形下(比如进入统一休眠期)确定冻结***应用,参见后文中的描述。
下面以***应用1为例,描述挂起***应用1使用的Alarm资源、Wakelock资源、广播资源、网络资源的可能的实现方式。
(1)Alarm资源
通常情况下,应用需要与该应用对应的应用服务器保持连接状态,以便该应用服务器可以向该应用执行数据的发送。各个应用与对应的应用服务器在进行连接之后才能进行数据的交互,或者各个应用与对应的应用服务器在进行连接之后才能进行应用之间数据的交互。应用服务器可以根据应用的状态(在线、离线)来决定是否需要向应用发送数据,所以应用可以使用Alarm资源定时向应用服务器发送心跳消息,来表示自己为在线状态,该心跳消息用于说明应用的状态为在线状态。
应用管控模块若确定挂起***应用1使用的Alarm资源,由于Alarm资源为按照包名管控的资源,则应用管控模块可以判断***应用1的包名是否为共享包名,若是,则指示资源管控模块按照***应用1的PID(或者包名和PID)挂起***应用1使用的Alarm资 源,若否,则指示资源管控模块按照***应用1的包名挂起***应用1使用的Alarm资源。相应地,资源管控模块可以通知Alarm代理按照***应用1的包名和/或PID将***应用1使用的Alarm资源代理起来。如此,Alarm代理可以按照***应用1的包名和/或PID遍历所有正在被使用的Alarm资源,找到***应用1的包名和/或PID对应的Alarm资源,并将Alarm的定时时间往后延迟预设时长(比如1年),从而达到暂停Alarm的效果,使得***应用1的心跳暂停。示例性地,Alarm代理可以为alarmmanagerservice。
需要说明的是,上述描述中,挂起***应用1使用的Alarm资源是指暂停***应用1的心跳;在其它可能的实施例中,挂起***应用1使用的Alarm资源也可以是指对***应用1的心跳进行统一,比如可以设置一个统一心跳的周期,从而使得***应用1按照该统一心跳的周期进行心跳。示例性地,可以按照***应用1的包名和/或PID对***应用1的心跳进行统一。其中,统一心跳和暂停心跳的差异之处在于:暂停心跳时,是将Alarm的定时时间往后延迟预设时长(比如1年),从而达到暂停心跳的效果;而统一心跳,则可以将Alarm的定时时间往后延迟第八时长(第八时长可以是基于Alarm的定时时间和统一心跳的周期得到的,比如,Alarm的定时时间为1分钟,统一心跳的周期为2分钟,则第八时长可以为1分钟),从而到达统一心跳的效果。
(2)广播资源
***应用1可以通过广播资源接收手机中的其它应用发送的广播。本申请实施例中,广播的发送方发送广播消息,可以有多个接收方。接收方可以指定接收哪些广播。发送方也可以指定发送给哪些接收方。接收方接收广播后可以在后台活动或者更新自己的状态。如果已经指定哪些发送方或者接收方时,广播代理在接收到发送方的广播后,无需一一查询哪个接收方需要接收这种广播,而是直接发送到指定的接收方中去。当然,如果发送方没有指定哪些接收方接收广播,或者接收方没有指定哪些发送方发送广播时,广播就会通过发送方发送到手机的广播代理中,由广播代理分发广播到相应的接收方中(在收发广播之前,接收方已经提前注册好需要接收哪种广播,当广播代理收到这些广播时,自动将这些广播分发到对应的应用中)。
应用管控模块若确定挂起***应用1使用的广播资源,由于广播资源为按照包名管控的资源,则应用管控模块可以判断***应用1的包名是否为共享包名,若是,则指示资源管控模块按照***应用1的PID(或者包名和PID)挂起***应用1使用的广播资源,若否,则指示资源管控模块按照***应用1的包名挂起***应用1使用的广播资源。相应地,资源管控模块可以通知广播代理按照***应用1的包名和/或PID将***应用1要接收的广播代理起来。如此,当广播代理接收到要发送给***应用1或***应用1的进程的广播后,可以将该广播先缓存起来。
需要说明的是,广播代理按照***应用1的包名和/或PID将***应用1要接收的广播代理起来时,可以是将***应用1要接收的所有广播代理起来,或者也可以是将***应用1要接收的部分广播代理起来,比如,将预设类型的广播代理起来,而非预设类型的广播可以不代理。其中,预设类型可以由本领域技术人员根据实际需要来设置,比如预设类型的广播可以包括提醒电量的广播。
(3)Wakelock资源
Wakelock是一种锁的机制,只要有应用占用该锁,CPU则无法进入休眠状态。比如,手机屏幕在屏幕关闭的时候,有些应用依然可以唤醒屏幕提示用户消息,即是用到了 Wakelock锁机制。
应用管控模块若确定挂起***应用1使用的Wakelock资源,由于Wakelock资源为按照UID管控的资源,则应用管控模块可以判断***应用1的UID是否为共享包名,若是,则指示资源管控模块按照***应用1的PID(或者UID和PID)挂起***应用1使用的Wakelock资源,若否,则指示资源管控模块按照***应用1的UID挂起***应用1使用的Wakelock资源。相应地,资源管控模块可以通知Wakelock代理按照UID和/或PID将***应用1使用的Wakelock资源代理起来。如此,Wakelock代理可以按照***应用1的UID和/或PID遍历所有正在被使用的Wakelock资源,找到***应用1的UID和/或PID对应的Wakelock资源,并存入缓存中。示例性地,Wakelock代理可以为powermanagerservice。
(4)网络资源
应用管控模块若确定挂起***应用1使用的网络资源,由于网络资源为按照UID管控的资源,则应用管控模块可以判断***应用1的UID是否为共享UID,若是,则指示资源管控模块按照***应用1的PID(或者UID和PID)挂起***应用1的网络资源,若否,则指示资源管控模块按照***应用1的UID挂起***应用1使用的网络资源。相应地,资源管控模块按照UID和/或PID挂起***应用1使用的网络资源。
三,对***应用解除冻结
本申请实施例中,对***应用解除冻结可以包括解除对***应用使用资源的限制或者说恢复***应用所使用的资源,处于活跃状态的***应用可以无限制地使用资源。
示例性地,应用管控模块可以在多种可能的情形下确定对***应用解除冻结,比如在进入统一活跃期或者有其它应用调用***应用时,可以确定对***应用解除冻结,参见后文中的描述。
下面仍以***应用1为例,描述恢复***应用1使用的Alarm资源、Wakelock资源、广播资源、网络资源的可能的实现方式。
(1)Alarm资源
应用管控模块若确定恢复***应用1使用的Alarm资源,由于Alarm资源为按照包名管控的资源,则应用管控模块可以判断***应用1的包名是否为共享包名,若是,则指示资源管控模块按照***应用1的PID(或者包名和PID)恢复***应用1使用的Alarm资源,若否,则指示资源管控模块按照***应用1的包名挂起***应用1使用的Alarm资源。相应地,资源管控模块可以通知Alarm代理按照***应用1的包名和/或PID恢复***应用1使用的Alarm资源。如此,Alarm代理可以按照***应用1的包名和/或PID遍历所有已被延迟的Alarm,找到***应用1的包名和/或PID对应的Alarm,恢复给***应用1使用。
(2)广播资源
应用管控模块若确定恢复***应用1使用的广播资源,由于广播资源为按照包名管控的资源,则应用管控模块可以判断***应用1的包名是否为共享包名,若是,则指示资源管控模块按照***应用1的PID(或者包名和PID)恢复***应用1使用的广播资源,若否,则指示资源管控模块按照***应用1的包名恢复***应用1使用的广播资源。相应地,资源管控模块可以通知广播代理按照***应用1的包名和/或PID恢复***应用1使用的广播资源。如此,广播代理可以遍历缓存中已经被代理的广播,找到***应用1的包名和/或PID对应的广播,并将广播发送给***应用1。
(3)Wakelock资源
应用管控模块若确定恢复***应用1使用的Wakelock资源,由于Wakelock资源为按照UID管控的资源,则应用管控模块可以判断***应用1的UID是否为共享包名,若是,则指示资源管控模块按照***应用1的PID(或者UID和PID)恢复***应用1使用的Wakelock资源,若否,则指示资源管控模块按照***应用1的UID挂起***应用1使用的Wakelock资源。相应地,资源管控模块可以通知Wakelock代理按照UID和/或PID恢复***应用1使用的Wakelock资源。如此,Wakelock代理可以按照***应用1的UID和/或PID遍历缓存中已被代理的Wakelock资源,找到***应用1的UID和/或PID对应的Wakelock资源,恢复给***应用1使用。
(4)网络资源
应用管控模块若确定恢复***应用1使用的网络资源,由于网络资源为按照UID管控的资源,则应用管控模块可以判断***应用1的UID是否为共享UID,若是,则指示资源管控模块按照***应用1的PID(或者UID和PID)恢复***应用1使用的网络资源,若否,则指示资源管控模块按照***应用1的UID恢复***应用1使用的网络资源。相应地,资源管控模块按照UID和/或PID恢复***应用1使用的网络资源。
四,统一休眠期和统一活跃期
在一种可能的实现方式中,统一休眠期的时长和统一活跃期的时长可以是默认的,比如可以为手机出厂前即已设置好的。
在又一种可能的实现方式中,统一休眠期的时长和统一活跃期的时长可以是用户设置的。比如,可以预先在设置应用中增添设置统一休眠期的时长和统一活跃期的时长的选项;如此,当用户需要设置统一休眠期的时长和统一活跃期的时长时,可以打开设置应用,进而基于相应的选项来进行设置。
在又一种可能的实现方式中,统一休眠期和/或统一活跃期可以是根据一个或多个***应用的业务需求确定的,其中,***应用的业务需求可以理解为***应用需要周期性执行的业务,比如,前文中所描述的***应用1需要周期性执行定位业务。
示例性地,***应用可以根据自身的业务需求确定休眠期和活跃期,其中,***应用的休眠期可以理解为***应用执行业务的周期,即***应用的活动周期;***应用的活跃期可以理解为***应用执行一次业务所需的时长,即***应用的活动时长;进而,***应用可以将休眠期和活跃期上报给注册回调模块(若***应用不需要执行周期性业务,或者说***应用不具有休眠期和活跃期,则可以不向注册回调模块上报),由注册回调模块发送给应用管控模块;相应地,应用管控模块可以根据一个或多个***应用的休眠期和活跃期确定统一休眠期和统一活跃期。其中,***应用可以在启动后便将休眠期和活跃期上报给注册回调模块,或者也可以在启动一段时间后将休眠期和活跃期上报给注册回调模块,本申请实施例对***应用上报休眠期和活跃期的时间不做限定。
在该实现方式的一个示例中,应用管控模块根据一个或多个***应用的休眠期,确定每个***应用的休眠期中的最短休眠期是否小于第二时长,若否,则将最短休眠期确定为统一休眠期,若是,则将第二时长确定为统一休眠期。其中,第二时长可以由本领域技术人员根据实际需要和经验来设置,比如第二时长为5分钟。举个例子,一个或多个***应用可以包括***应用1、***应用2和***应用3,其中,***应用1的休眠期可以为***应 用1的活动周期,即为5分钟,***应用2的休眠期可以为***应用2的活动周期,即为6分钟,***应用3的休眠期可以为***应用3的活动周期,即为9分钟。***应用1、***应用2和***应用3的最短休眠期为5分钟,且最短休眠期等于第二时长,因此,可以将最短休眠期(即5分钟)确定为统一休眠期。
在该实现方式的又一个示例中,应用管控模块根据一个或多个***应用的活跃期,确定每个***应用的休眠期中的最长活跃期是否大于或等于第三时长,若否,则将最长活跃期确定为统一活跃期,若是,则将第三时长确定为统一活跃期。其中,第三时长可以由本领域技术人员根据实际需要和经验来设置,比如第三时长为1分钟。举个例子,一个或多个***应用可以包括***应用1、***应用2和***应用3,其中,***应用1的活跃期可以为***应用1的活动时长,即为30秒,***应用2的活跃期可以为***应用2的活动时长,即为36秒,***应用3的活跃期可以为***应用3的活动时长,即为30秒。***应用1、***应用2和***应用3的最长活跃期为36秒,且最长活跃期小于第三时长(1分钟),因此,可以将最长活跃期确定为统一活跃期。
在该种实现方式中,可以在符合一定的条件时,对统一休眠期和统一活跃期进行更新。比如,当有新的***应用(比如***应用4)上报休眠期和活跃期后,则可以根据***应用1、***应用2、***应用3和***应用4的休眠期和活跃期对统一休眠期和统一活跃期进行更新。
基于上述对相关技术特征的介绍,下面结合一些可能的场景(比如场景1和场景2),对本申请实施例提供的***应用的管理方法进行描述。
场景1
图5a为本申请实施例场景1提供的一种***应用的管理方法所对应的流程示意图,图5b为本申请实施例场景1提供的又一种***应用的管理方法所对应的流程示意图。下面结合图5a和图5b进行描述。
如图5a和图5b所示,该方法包括:
步骤501,激活***应用的管理功能。
示例性地,激活***应用的管理功能的方式可以有多种。在一种可能的实现方式中,可以通过用户的触发来激活***应用的功能。比如,可以预先在设置应用中增添激活或去激活***应用的管理功能的按钮;如此,当用户需要激活***应用的管理功能时,可以打开设置应用,通过触发按钮来激活***应用的管理功能,当用户需要去激活***应用的管理功能时,可以打开设置应用,通过触发按钮来去激活***应用的管理功能。在又一种可能的实现方式中,***应用的管理功能可以默认处于激活状态,比如电子设备开机时,***应用的管理功能即激活,电子设备关机时,***应用的管理功能即去激活。
步骤502,若电子设备进入第一模式,则启动计时器1。
此处,第一模式可以包括灭屏模式或休眠模式。
以Android操作***为例,Android操作***可以预先定义一个计时器(比如计时器1),当检测到电子设备处于第一模式时,***查找预先定义的计时器1,并通过调用timer.setbase(systemclock.elapsedrealtime())这一函数将计时器1清零,然后通过调用timer.start()这一函数启动计时器1,开始计时。
步骤503,若计时器1的时长大于或等于第一时长,则进入维护期。其中,维护期内可 以包括至少一个统一休眠期,还可以包括至少一个统一活跃期;当维护期内包括多个统一休眠期和多个统一活跃期时,统一休眠期和统一活跃期可以循环出现。
示例性地,第一时长可以由本领域技术人员根据实际需要和经验进行设置,比如第一时长可以为30秒。
需要说明的是,进入维护期后,可以先出现统一休眠期再出现统一活跃期,或者也可以先出现统一活跃期再出现统一休眠期,具体不做限定。下文中仅是以先出现统一休眠期再出现统一活跃期为例进行描述的。
步骤504,在统一休眠期(该统一休眠期可以为维护期内出现的至少一个统一休眠期中的任一个统一休眠期,为便于描述,称为统一休眠期1)内,对处于后台运行状态的至少一个***应用进行冻结;在统一活跃期(该统一活跃期可以为统一休眠期1之后第一次出现的统一活跃期,为便于描述,称为统一活跃期1)内,对至少一个***应用解除冻结。
示例性地,判断***应用是否处于后台运行状态的实现方式可以有多种。在一种可能的实现方式中,当***应用(以***应用1为例)被打开后,Android操作***会调用onResume等方法来使***应用1的activity处于运行状态。其中,activity是一个应用程序组件。若***应用1具有可视的显示界面,则在***应用1的activity启动后,activity包括:运行Resumed状态、暂停Paused状态以及停止Stopped状态;进而,如果***应用1的activity处于Resumed状态,则表示***应用1处于前台运行状态,而如果***应用1的activity处于Paused状态,则表示***应用1处于后台运行状态。若***应用1不具有可视的显示界面,则在***应用1的activity启动后,activity包括:Resumed状态、Stopped状态;进而,如果***应用1的activity处于Resumed状态,则表示***应用1处于后台运行状态。如此,可以根据***应用的activity所处的状态,来判断***应用是否处于后台运行状态。
示例性地,上述至少一个***应用均为未处于冻结状态的***应用,比如可以对***应用的状态进行标记,进而通过读取***应用的状态标识可以获知***应用是否处于冻结状态。
示例性地,在统一休眠期1内,对至少一个***应用进行冻结,包括:在统一休眠期1内,判断至少一个***应用中的每个***应用是否符合第一预设条件,若符合,则对至少一个***应用中的每个***应用进行冻结。其中,至少一个***应用包括***应用1,以***应用1为例,***应用1符合第一预设条件可以理解为***应用1不具有可感知业务,且***应用1未注册保活。也就是说,在统一休眠期1内,检测到***应用1不具有可感知业务,且未注册保活,则可以对***应用1进行冻结。若检测到***应用1具有可感知业务或者***应用1注册了保活(比如注册了保活1分钟),则暂时不对***应用1进行冻结;此种情形下,可以按照设定周期(比如30s)检测***应用1的可感知业务是否结束或者是否到达保活时长,从而在检测到***应用1的可感知业务结束或者到达保活时长后,对***应用1进行冻结。其中,对***应用进行冻结的具体实现可以参见上文中有关冻结***应用的相关描述,此处不再赘述。
其中,可感知业务可以理解为可以被用户听到、看到等可被用户感知到的业务,例如播放音乐、下载文件等,但不限于此。若***应用1具有可感知业务,则虽然***应用1已进入到后台运行,但依然可被用户感知到***应用1正在执行业务,此种情形下,可以不对***应用1进行冻结。
由于***应用可能需要执行紧急业务(或者说不可推迟的业务),此种情形,若进入统一休眠期时,***应用的紧急业务尚未执行完,此时,对***应用进行冻结可能导致该紧急业务无法被正常执行。基于此,本申请实施例提供一种注册保活机制,从而保证紧急业务的正常执行。比如***应用1确定有紧急业务需要处理,则可以根据紧急业务需要处理的时长,来注册保活时长,在***应用1的保活时长内,可以不对***应用1进行冻结。
示例性地,***应用注册保活时,可以是注册保活***应用所使用的全部资源,或者也可以是注册保活***应用所使用的一种或多种资源,比如注册保活广播资源。此种情形下,上文的描述中,若在统一休眠期1内,***应用注册了保活,则在***应用的保活时长内,不对***应用进行冻结,可以是指,若在统一休眠期1内,***应用注册了保活全部资源,则在***应用的保活时长内,不对***应用进行冻结。若在统一休眠期1内,***应用注册保活广播资源,则在***应用的保活时长内,可以对***应用进行冻结,但此时仅限制***应用1所使用的除广播资源以外的其它资源,而不限制***应用使用广播资源。本申请实施例中,若无特殊说明,则***应用注册保活可以理解为***应用注册保活全部资源。
本申请实施例中,在统一休眠期1内,还可以对***应用解除冻结,比如在一个示例中,从***应用的角度来看,在统一休眠期内,若确定某一***应用需要解除冻结,则可以对该***应用解除冻结。其中,确定某一***应用需要解除冻结的情形可以有多种,比如若***应用1处于冻结状态,且限制***应用1使用全部资源,则当有其它应用调用***应用1时,可以确定对***应用1解除冻结;又比如,若***应用1处于冻结状态,限制***应用1使用部分资源而未限制***应用1使用广播资源(或者仅限制部分广播资源),则当有其它应用调用***应用1或者***应用1需要接收广播时,可以确定对***应用1解除冻结。具体可以由本领域技术人员根据实际需要设置需要解除冻结的各种可能的情形,本申请实施例对此不做限定。
进一步地,在统一休眠期内对***应用1解除冻结后,***应用1处于活跃状态,若***应用1处于活跃状态的时长大于或等于第六时长时,仍处于统一休眠期内,则可以再次对***应用1进行冻结。其中,第六时长可以由本领域技术人员根据实际需要和经验来设置,具体不做限定,比如第六时长可以为6秒。
本申请实施例中,若电子设备进入第二模式,则可以退出维护期,其中,第二模式可以包括亮屏模式。示例性地,退出维护期时,可以对处于冻结状态的***应用解除冻结。
可以理解地,维护期的时长与电子设备处于第一模式的时长相关,比如,电子设备处于第一模式的时长较长,则维护期的时长较长;电子设备处于第一模式的时长较短,则维护期的时长也较短。上述方案主要是基于维护期包括至少一个休眠期和至少一个活跃期的情形进行描述的,在其它可能的实施例中,也有可能出现维护期的时间较短的情形,比如维护期的时长可能小于或等于统一休眠期的时长,此种情形下,也可以按照上述方案来执行。
此外,本申请实施例还可以对***应用使用资源的情况进行统计,若确定某一***应用在预设时间段内所使用的资源量大于或等于预设阈值,则可以向该***应用发出资源使用超标的提示,从而便于该***应用进行自检和修复。其中,预设时间段可以由本领域技术人员根据实际需要和经验来设置,具体不做限定。
举个例子,预设时间段的时长可以小于或等于统一活跃期的时长,比如可以在统一活 跃期内,统计***应用在预设时间段内使用资源的情况,若使用的资源量大于或等于预设阈值,则可以向该***应用发出提示。其中,使用的资源量可以从多个角度来衡量,比如,以Wakelock资源为例,可以从使用Wakelock资源的时长的角度来衡量其使用的资源量,若使用Wakelock资源的时长(比如可以根据资源管控模块所记录的使用Wakelock资源的开始时间和当前时间来确定使用Wakelock资源的时长)大于或等于第七时长(可以为预先设置的一个时长),则可以理解为使用的资源量大于或等于预设阈值。在其它可能的实施例中,也可以从其它可能的角度来衡量,具体不做限定。
需要说明的是,若统一休眠期和统一活跃期是基于至少一个***应用注册的休眠期和活跃期确定的,则针对于未向注册回调模块注册休眠期和活跃期的***应用,为便于描述,以该***应用为***应用5为例,***应用5处于后台运行状态,由于***应用5未注册休眠期和活跃期,说明***应用可能不需要执行周期性业务,因此,可以不对***应用5进行管控,或者,也可以按照对至少一个***应用的管控方式对***应用5进行管控,即若在统一休眠期内,则对***应用5进行冻结;若在统一活跃期内,则对***应用5解除冻结。也就是说,若统一休眠期和统一活跃期是基于***应用1、***应用2和***应用3上报的休眠期和活跃期确定的,则可以基于统一休眠期和统一活跃期仅对***应用1、***应用2和***应用3进行管控,或者,也可以基于统一休眠期和统一活跃期对***应用1、***应用2和***应用3以及其它处于后台运行状态的***应用进行管控。
下面结合图3b描述采用本申请实施例提供的***应用的管理方法后,相比于现有技术(图3a)的区别。如图3b所示,假设上述图5a中所描述的至少一个***应用包括***应用1、***应用2和***应用3,可以看出,在t0至t1这段时间内,***应用1、***应用2、***应用3共活动7次,但Android操作***仅被唤醒3次,从而能够有效减少电量消耗。
场景2
图6a为本申请实施例场景2提供的一种***应用的管理方法所对应的流程示意图,图6b为本申请实施例场景2提供的又一种***应用的管理方法所对应的流程示意图。下面结合图6a和图6b进行描述。
如图6a和图6b所示,该方法包括:
步骤601,激活***应用的管理功能。
此处,步骤601的具体实现可以参照上述步骤501的相关描述。
步骤602,启动计时器2。
以Android操作***为例,Android操作***可以预先定义一个计时器(称为计时器2),当激活***应用的管理功能后,***查找预先定义的计时器2,并通过调用timer.setbase(systemclock.elapsedrealtime())这一函数将计时器2清零,然后通过调用timer.start()这一函数启动计时器2,开始计时。
步骤603,若计时器2的时长大于或等于第四时长,则进入维护期。
示例性地,第四时长可以由本领域技术人员根据实际需要和经验进行设置,比如第一时长可以为30秒。
步骤604,确定某一***应用(为便于描述,以***应用1为例)在操作***中的运行状态为后台运行状态,则启动***应用1对应的计时器(称为计时器3)。
步骤605,计时器3的时长大于或等于第五时长时,若处于统一休眠期(比如统一休眠期2)内,则在统一休眠期2内对***应用1进行冻结;在统一休眠期2之后第一次出现的统一活跃期2内,对***应用1解除冻结。可以理解地,在***应用1处于后台运行状态的时间段内,在统一活跃期2之后出现的统一休眠期3内,可以再次对***应用1进行冻结,在统一休眠期3之后第一次出现的统一活跃期3内,对***应用1解除冻结,依次类推。
示例性地,第五时长可以由本领域技术人员根据实际需要和经验进行设置,比如第五时长可以为30秒。
示例性地,当计时器3的时长大于或等于第五时长时,若处于统一休眠期,且电子设备处于第二模式(比如亮屏模式),则判断***应用1是否符合第二预设条件,若符合,则对***应用1进行冻结。当计时器3的时长大于或等于第五时长时,若处于统一休眠期,且电子设备处于第一模式(比如灭屏模式),则判断***应用1是否符合第一预设条件,若符合,则对***应用1进行冻结。当计时器3的时长大于或等于第五时长时,若处于统一活跃期,则不对***应用1进行冻结。其中,***应用1符合第二预设条件可以理解为***应用1不具有可感知业务、***应用1未注册保活且***应用1不是前台运行的应用所依赖的***应用。***应用1符合第一预设条件可以参见上述场景1中的相关描述。
本申请实施例中,***应用1是前台应用所依赖的应用程序是指前台应用需要利用***应用1的数据才能执行。当前台应用的进程与***应用1的进程之间有通信机制时,则***应用1是前台应用所依赖的应用。其中,前台应用的进程与***应用1的进程之间有通信机制包括:(1)***应用1的进程与前台应用的进程之间有socket和binder通信中至少一种。(2)***应用1的进程与前台应用的进程之间有内存共享。(3)前台应用的进程等待在锁资源上的***应用1的进程,比如,当检测到发生锁资源等待时,可检测发生锁资源等待是否为前台应用程序的进程,若是,则遍历获取等待在该锁资源上的所有后台进程,上述等待在该锁资源上的所有后台进程均为前台应用程序的进程所依赖的后台进程。
本申请实施例中,在统一休眠期(可以是指统一休眠期2或者统一休眠期2之后的某个统一休眠期内)内,若确定***应用1需要解除冻结,则可以对***应用1解除冻结。其中,确定***应用1需要解除冻结的情形可以有多种,比如若***应用1处于冻结状态,且限制***应用1使用全部资源,则当有其它应用调用***应用1时,可以确定对***应用1解除冻结;又比如,若***应用1处于冻结状态,限制***应用1使用部分资源而未限制***应用1使用广播资源(或者仅限制部分广播资源),则当有其它应用调用***应用1或者***应用1需要接收广播时,可以确定对***应用1解除冻结;又比如,***应用1由后台运行状态切换为前台运行状态,可以确定对***应用1解除冻结。具体可以由本领域技术人员根据实际需要设置需要解除冻结的各种可能的情形,本申请实施例对此不做限定。
示例性地,若去激活***应用的管理功能,则可以退出维护期。退出维护期时,可以对处于冻结状态的***应用解除冻结。
此外,本申请实施例还可以对***应用1使用资源的情况进行统计,若确定***应用1在预设时间段内所使用的资源量大于或等于预设阈值,则可以向该***应用1发出提示,从而便于该***应用1进行自检和修复。
需要说明的是:场景1和场景2的差异之处在于:场景1中是在电子设备处于第一模 式时,基于统一休眠期和统一活跃期对处于后台运行状态的***应用所使用的资源进行管控;而场景2中不论电子设备处于第一模式或第二模式,均可以基于统一休眠期和统一活跃期对处于后台运行状态的***应用所使用的资源进行管控。除此差异之外的其它内容,二者可以相互参照。
根据上述描述可知,本申请实施例中,通过在统一休眠期限制后台运行的***应用使用资源,以及在统一活跃期解除对后台运行的***应用使用资源的限制,从而便于在后台运行的***应用统一活动,避免频繁唤醒操作***而导致电子设备的电量消耗较为严重。进一步地,考虑到***应用的包名可能为共享包名,UID可能为共享UID,因此可以在记录资源宿主时,除记录***应用的包名和UID之外,还可以进一步记录***应用的进程的PID,从而能够基于PID对***应用所使用的资源进行限制或解除限制,实现对***应用所使用的资源进行有效管控。
下面结合附图介绍本申请实施例提供的装置,以实现本申请上述方法实施例。
如图7所示,本申请另外一些实施例公开了一种电子设备,该电子设备可以包括:一个或多个处理器702,存储器703,一个或多个计算机程序704;上述各器件可以通过一个或多个通信总线705连接。其中,所述一个或多个计算机程序704被存储在上述存储器703中并被配置为被该一个或多个处理器702执行,该一个或多个计算机程序704包括指令,上述指令可以用于执行前述的图4a~图6b所示的实施例中记载的全部或部分步骤。
其中,处理器702可以是中央处理器(central processing unit,CPU),或特定应用集成电路(application-specific integrated circuit,ASIC),可以是一个或多个用于控制程序执行的集成电路,可以是基带芯片,等等。存储器703的数量可以是一个或多个,存储器703可以是只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)或磁盘存储器,等等。
图7所示的电子设备可以是手机、ipad、笔记本电脑、智能电视、穿戴式设备(例如智能手表、智能头盔或智能手环等)等。当图7所示的电子设备是手机时,其结构可以参见图1c所示,比如,存储器703是内部存储器121。
上述本申请提供的实施例中,从终端设备(手机100)作为执行主体的角度对本申请实施例提供的方法进行了介绍。为了实现上述本申请实施例提供的方法中的各功能,终端设备可以包括硬件结构和/或软件模块,以硬件结构、软件模块、或硬件结构加软件模块的形式来实现上述各功能。上述各功能中的某个功能以硬件结构、软件模块、还是硬件结构加软件模块的方式来执行,取决于技术方案的特定应用和设计约束条件。
上述实施例中所用,根据上下文,术语“当…时”可以被解释为意思是“如果…”或“在…后”或“响应于确定…”或“响应于检测到…”。类似地,根据上下文,短语“在确定…时”或“如果检测到(所陈述的条件或事件)”可以被解释为意思是“如果确定…”或“响应于确定…”或“在检测到(所陈述的条件或事件)时”或“响应于检测到(所陈述的条件或事件)”。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质 中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如DVD)、或者半导体介质(例如固态硬盘)等。
为了解释的目的,前面的描述是通过参考具体实施例来进行描述的。然而,上面的示例性的讨论并非意图是详尽的,也并非意图要将本申请限制到所公开的精确形式。根据以上教导内容,很多修改形式和变型形式都是可能的。选择和描述实施例是为了充分阐明本申请的原理及其实际应用,以由此使得本领域的其他技术人员能够充分利用具有适合于所构想的特定用途的各种修改的本申请以及各种实施例。

Claims (12)

  1. 一种***应用的管理方法,其特征在于,所述方法包括:
    进入维护期,所述维护期包括统一休眠期和统一活跃期;
    在所述统一休眠期内,对处于后台运行状态的***应用进行冻结;
    在所述统一休眠期之后出现的所述统一活跃期内,对所述***应用解除冻结。
  2. 根据权利要求1所述的方法,其特征在于,对所述***应用进行冻结,包括:挂起所述***应用所使用的部分或全部资源。
  3. 根据权利要求2所述的方法,其特征在于,所述***应用所使用的资源包括第一资源和/或第二资源;
    所述方法还包括:
    在所述***应用使用所述第一资源时,记录所述第一资源的资源宿主,所述第一资源的资源宿主包括所述***应用的用户标识符UID和所述***应用的第一进程的进程名或进程标识符PID;和/或,在所述***应用使用所述第二资源时,记录所述第二资源的资源宿主,所述第二资源的资源宿主包括所述***应用的包名和所述***应用的第二进程的进程名或PID。
  4. 根据权利要求3所述的方法,其特征在于,挂起所述第一资源,包括:若所述***应用的UID为共享UID,则根据所述第一进程的进程名或PID挂起所述第一资源;
    挂起所述第二资源,包括:若所述***应用的包名为共享包名,则根据所述第二进程的进程名或PID挂起所述第二资源。
  5. 根据权利要求1至4中任一项所述的方法,其特征在于,进入所述维护期,包括:
    激活***应用的管理功能后,若确定进入第一模式,则启动第一计时器;所述第一模式包括灭屏模式或休眠模式;
    若所述第一计时器的时长大于或等于第一时长,则进入所述维护期。
  6. 根据权利要求1至4中任一项所述的方法,其特征在于,进入所述维护期,包括:
    若激活***应用的管理功能,则启动第二计时器;
    若所述第二计时器的时长大于或等于第四时长,则进入所述维护期。
  7. 根据权利要求6所述的方法,其特征在于,在所述统一休眠期内,对处于后台运行状态的***应用进行冻结,包括:
    检测到所述***应用进入后台运行状态,启动所述***应用对应的第三计时器;
    若所述第三计时器的时长大于或等于第五时长时处于所述统一休眠期内,则对所述***应用进行冻结。
  8. 根据权利要求1至7中任一项所述的方法,其特征在于,对所述***应用进行冻结之前,还包括:
    确定所述***应用不具有可感知业务,且所述***应用未注册保活。
  9. 根据权利要求1至8中任一项所述的方法,其特征在于,所述方法还包括:
    根据所述***应用的休眠期,确定所述统一休眠期;其中,所述***应用的休眠期等于所述***应用的活动周期;
    根据所述***应用的活跃期,确定所述统一活跃期;其中,所述***应用的活跃期等于所述***应用的活动时长。
  10. 一种电子设备,其特征在于,包括:显示屏;一个或多个处理器;存储器;一个或多个程序;其中所述一个或多个程序被存储在所述存储器中,所述一个或多个程序包括指令,当所述指令被所述处理器执行时,使得所述电子设备执行如权利要求1-9中任一所述的方法步骤。
  11. 一种计算机可读存储介质,其特征在于,包括计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行如权利要求1-9中任一项所述的方法。
  12. 一种计算机程序产品,其特征在于,当所述计算机程序产品在电子设备上运行时,使得所述电子设备执行如权利要求1-9中任一项所述的方法。
PCT/CN2020/112213 2019-08-28 2020-08-28 一种***应用的管理方法及装置 WO2021037228A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910804027.9 2019-08-28
CN201910804027.9A CN110691401B (zh) 2019-08-28 2019-08-28 一种***应用的管理方法及装置

Publications (1)

Publication Number Publication Date
WO2021037228A1 true WO2021037228A1 (zh) 2021-03-04

Family

ID=69108451

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/112213 WO2021037228A1 (zh) 2019-08-28 2020-08-28 一种***应用的管理方法及装置

Country Status (2)

Country Link
CN (1) CN110691401B (zh)
WO (1) WO2021037228A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110691401B (zh) * 2019-08-28 2021-04-09 华为技术有限公司 一种***应用的管理方法及装置
WO2023225859A1 (zh) * 2022-05-24 2023-11-30 云智联网络科技(北京)有限公司 虚拟直播软件终端优化方法、装置、电子设备和程序产品

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150160976A1 (en) * 2013-12-06 2015-06-11 Samsung Electronics Co., Ltd. Multitasking method and electronic device therefor
CN106484472A (zh) * 2016-09-29 2017-03-08 华为技术有限公司 一种内存回收方法及终端
CN109684069A (zh) * 2017-10-13 2019-04-26 华为技术有限公司 资源管理的方法及终端设备
CN109992380A (zh) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 应用程序处理方法和装置、电子设备、计算机可读存储介质
CN109992375A (zh) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 信息处理方法、装置、计算机设备和计算机可读存储介质
CN110046032A (zh) * 2018-01-12 2019-07-23 广东欧珀移动通信有限公司 应用程序处理方法和装置、电子设备、计算机可读存储介质
CN110167113A (zh) * 2019-04-17 2019-08-23 努比亚技术有限公司 一种设备控制方法、可穿戴设备及计算机可读存储介质
CN110691401A (zh) * 2019-08-28 2020-01-14 华为技术有限公司 一种***应用的管理方法及装置

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9952897B2 (en) * 2011-09-12 2018-04-24 Microsoft Technology Licensing, Llc Managing processes within suspend states and execution states
CN102981906A (zh) * 2012-11-16 2013-03-20 广东欧珀移动通信有限公司 一种应用程序后台进程管理方法及装置
CN103092691B (zh) * 2013-01-23 2019-03-01 Oppo广东移动通信有限公司 一种安卓***的进程管理方法和管理单元
CN105159776B (zh) * 2015-08-03 2019-02-19 中科创达软件股份有限公司 进程处理方法及装置
CN105677460B (zh) * 2015-12-28 2019-07-23 小米科技有限责任公司 应用程序处理方法以及装置
CN106125882B (zh) * 2016-06-15 2019-04-26 深圳市万普拉斯科技有限公司 一种应用程序的管理方法以及电子设备
CN106648849A (zh) * 2016-10-18 2017-05-10 上海传英信息技术有限公司 进程的冷冻方法和移动终端
CN106502371A (zh) * 2016-11-08 2017-03-15 珠海市魅族科技有限公司 一种省电控制方法以及装置
CN106991003B (zh) * 2017-03-06 2023-07-07 宇龙计算机通信科技(深圳)有限公司 冻结和解冻文件夹内批量应用程序的方法及***
JP2020537211A (ja) * 2017-10-13 2020-12-17 ホアウェイ・テクノロジーズ・カンパニー・リミテッド アプリケーション管理方法および端末
CN109992310B (zh) * 2019-03-12 2024-04-05 中国平安财产保险股份有限公司 应用程序保活方法、装置、计算机设备和存储介质

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150160976A1 (en) * 2013-12-06 2015-06-11 Samsung Electronics Co., Ltd. Multitasking method and electronic device therefor
CN106484472A (zh) * 2016-09-29 2017-03-08 华为技术有限公司 一种内存回收方法及终端
CN109684069A (zh) * 2017-10-13 2019-04-26 华为技术有限公司 资源管理的方法及终端设备
CN109992380A (zh) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 应用程序处理方法和装置、电子设备、计算机可读存储介质
CN109992375A (zh) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 信息处理方法、装置、计算机设备和计算机可读存储介质
CN110046032A (zh) * 2018-01-12 2019-07-23 广东欧珀移动通信有限公司 应用程序处理方法和装置、电子设备、计算机可读存储介质
CN110167113A (zh) * 2019-04-17 2019-08-23 努比亚技术有限公司 一种设备控制方法、可穿戴设备及计算机可读存储介质
CN110691401A (zh) * 2019-08-28 2020-01-14 华为技术有限公司 一种***应用的管理方法及装置

Also Published As

Publication number Publication date
CN110691401B (zh) 2021-04-09
CN110691401A (zh) 2020-01-14

Similar Documents

Publication Publication Date Title
CN108512695B (zh) 监控应用卡顿的方法及装置
KR102148948B1 (ko) 전자 장치의 멀티 태스킹 방법 및 그 전자 장치
US10503371B2 (en) Virtual tabs supporting web content suspension
KR101680796B1 (ko) 사용자 활동에 기초한 모바일 디바이스의 동적 조정
US11151017B2 (en) Method for processing refresh and display exceptions, and terminal
WO2020024732A1 (zh) 进程处理方法、电子设备、计算机可读存储介质
US9584438B2 (en) Idle worker-process page-out
WO2021037228A1 (zh) 一种***应用的管理方法及装置
WO2020093208A1 (zh) 应用程序处理方法和装置、计算机设备、计算机可读存储介质
US20150095758A1 (en) Web content suspension compatibility and suspended web content lifetime
CN106658064B (zh) 虚拟礼物展示方法及装置
CN110032321B (zh) 应用程序处理方法和装置、电子设备、计算机可读存储介质
WO2019128588A1 (zh) 进程处理方法和装置、电子设备、计算机可读存储介质
CN112732434A (zh) 一种应用管理方法及装置
WO2019128573A1 (zh) 信息处理方法、装置、计算机设备和计算机可读存储介质
WO2019128586A1 (zh) 应用程序处理方法、电子设备、计算机可读存储介质
WO2017014919A1 (en) Background task management
WO2019128553A1 (zh) 应用程序处理方法、电子设备、计算机可读存储介质
WO2022213757A1 (zh) 应用界面的显示方法、装置、设备及存储介质
CN109992369B (zh) 应用程序处理方法和装置、电子设备、计算机可读存储介质
WO2022188667A1 (zh) 转屏处理方法、装置、介质及电子设备
CN113568748B (zh) 一种应用进程处理方法、装置、存储介质及电子设备
CN115017004A (zh) 进程监控方法及电子设备
WO2019128562A1 (zh) 应用冻结方法、装置、终端及计算机可读存储介质
WO2022179283A1 (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: 20857641

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20857641

Country of ref document: EP

Kind code of ref document: A1