System shutdown control method and device, electronic equipment and readable storage medium

By acquiring and processing multiple target tasks before the system shuts down and determining the processing order according to the task type, the problem that some tasks in the prior art cannot be processed before the system shuts down is solved, and a more flexible and efficient system shutdown process is achieved.

CN120104260APending Publication Date: 2025-06-06HUAWEI TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202311656758.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-05
Publication Date
2025-06-06

AI Technical Summary

Technical Problem

Existing system shutdown methods cause some types of pending tasks to be processed before shutdown, lacking flexibility and scalability.

Method used

By responding to the shutdown operation, multiple target tasks and their task types are obtained before the system shutdown, the processing order is determined according to the task type, and the target application is controlled to process the target tasks until all tasks are completed, and the system shutdown is executed.

Benefits of technology

It effectively avoids data loss or corruption during system shutdown, meets the pending needs of different types of tasks, and improves the flexibility of system shutdown.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120104260A_ABST
    Figure CN120104260A_ABST
Patent Text Reader

Abstract

The invention provides a system shutdown control method and device, electronic equipment and a readable storage medium, and relates to the technical field of terminals.The control method comprises the steps that in response to shutdown operation, a plurality of target tasks to be processed before system shutdown and the task type of each target task are obtained; determining a processing sequence of the plurality of target tasks according to the task type of each target task; according to the processing sequence of the multiple target tasks, controlling a target application corresponding to each target task to process the target task; after the multiple target tasks are processed, the system is controlled to be shut down. Before the system is shut down, according to the processing type of each to-be-processed target task, each target application is controlled to process the corresponding target task according to a certain sequence, the processing requirements of different types of target tasks before the system is shut down are met, and the flexibility of the system shutdown is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a method, device, electronic device and readable storage medium for controlling system shutdown. Background Art

[0002] The system shutdown process is a power management technology of mobile operating systems such as the iPhone operating system (IOS) and Android. Taking the Android operating system in electronic devices as an example, after the operating system detects the shutdown operation triggered by the user, it generally first notifies the application that has subscribed to receive the shutdown broadcast through an asynchronous shutdown broadcast to handle the tasks before shutdown, and then shuts down the activity management service (AMS), package management service (PMS), radios service and kernel system in a fixed order to realize system shutdown.

[0003] Among them, the types of tasks that electronic devices need to process before shutting down are diverse, such as system or application upgrades, document saving, and data persistent storage. When shutting down based on the existing system shutdown method, only some applications can complete the processing of corresponding tasks before the system shuts down by listening to the shutdown broadcast, but other applications that cannot receive the monitoring broadcast will stop running when the system service is shut down, resulting in some tasks being unable to be processed before the system shuts down. Summary of the invention

[0004] The present application provides a system shutdown control method, device, electronic device and readable storage medium, which can to a certain extent solve the technical problem that some types of pending tasks cannot be processed before shutdown due to the existing system shutdown method.

[0005] In order to achieve the above purpose, this application adopts the following technical solutions:

[0006] In a first aspect, the present application provides a method for controlling system shutdown, the method comprising: in response to a shutdown operation, obtaining multiple target tasks to be processed before system shutdown and the task type of each target task; determining a processing order of the multiple target tasks according to the task type of each target task; controlling a target application corresponding to each target task to process the target task according to the processing order of the multiple target tasks; and controlling system shutdown after the processing of the multiple target tasks is completed.

[0007] Based on the system shutdown control method provided in the embodiment of the present application, after the user triggers the shutdown operation on the electronic device, the operating system of the electronic device can obtain all target tasks that need to be processed before the system shuts down, and according to the task type of different target tasks, control the target application corresponding to each target task in a certain processing order to complete the processing of the target task before the system shuts down, and then execute the subsequent system shutdown process. This control method can effectively avoid the loss or damage of data of various target applications in the running state of the electronic device when the system is shut down, meet the processing requirements of different types of target tasks before the system is shut down, and improve the flexibility of the system shutdown method.

[0008] Optionally, the operating system obtains multiple target tasks to be processed before system shutdown and the task type of each target task as follows: when the target application corresponding to each target task starts running, it can send to the operating system one or more target tasks that it may need to process before system shutdown, and send the task type of the target task at the same time.

[0009] Exemplarily, the target application may determine the task type of the corresponding target task according to the application type and / or the processing method of the target task.

[0010] Among them, the shutdown operation can be used to instruct to shut down the electronic device or restart the electronic device. If the shutdown operation is used to instruct to restart the electronic device, then after the multiple target tasks are processed, the subsequent system shutdown process includes but is not limited to shutting down various system services, shutting down the system kernel, restarting the system kernel, and restarting various system services. If the shutdown operation is used to instruct to shut down the electronic device, then after the multiple target tasks are processed, the subsequent system shutdown process includes but is not limited to shutting down various system services, shutting down the system kernel, and powering off all hardware in the electronic device.

[0011] The electronic devices involved in the control method provided in the embodiments of the present application are mobile phones, tablet computers, wearable devices, and other devices that can be installed with mobile operating systems such as Android, Apple, or Hongmeng.

[0012] In a possible implementation of the first aspect, the method further includes: obtaining a priority level of each target task;

[0013] According to the task type of each target task, the processing order of multiple target tasks is determined, including: according to the corresponding relationship between the preset task type and the processing order, the multiple target tasks are sorted to obtain a first sorting result; according to the priority level of each target task, the order of the target tasks with the same task type in the first sorting result is adjusted to obtain a second sorting result; based on the second sorting result, the processing order of multiple target tasks is determined.

[0014] Based on this possible implementation, when each target application sends the corresponding target task to the operating system, it can also send the priority level of the corresponding target task to the operating system. The operating system can determine the processing order of multiple target tasks of the same task type according to the order of priority from high to low. Exemplarily, all tasks corresponding to all applications that can be run in the electronic device can be divided into at least two priority levels.

[0015] In a possible implementation of the first aspect, the processing order of multiple target tasks is determined based on the second sorting result, including: obtaining the generation time of each target task; adjusting the order of target tasks with the same priority level and the same task type in the second sorting result according to the generation time of each target task, to obtain the processing order of multiple target tasks.

[0016] Based on this possible implementation, the generation time of the target task can be the time when the operating system receives the target application corresponding to the target task and sends the target task to the operating system. The operating system can determine the processing order of multiple target tasks with the same priority level and the same task type according to the order of generation time from earliest to latest.

[0017] In a possible implementation of the first aspect, according to the processing order of multiple target tasks, the target application corresponding to each target task is controlled to process the target task, including: according to the processing order of multiple target tasks, a system shutdown notification is sent to the target application corresponding to each target task in turn, and the system shutdown notification is used to instruct the target application to process the corresponding target task.

[0018] In a possible implementation of the first aspect, the multiple target tasks include a first task whose task type is to take over shutdown, and the target application corresponding to the first task is a first application;

[0019] According to the processing order of multiple target tasks, a system shutdown notification is sent to the target application corresponding to each target task in turn, including: sending a system shutdown notification to a first application; receiving a shutdown takeover notification sent by the first application, the shutdown takeover notification being used to instruct the first application to confirm to continue processing the first task based on the system shutdown notification; pausing system shutdown based on the shutdown takeover notification; receiving a task completion notification sent by the first application; and according to the task completion notification and the processing order of multiple target tasks, sending a system shutdown notification to a target application corresponding to the next target task of the first task.

[0020] Among them, the first task that can take over the shutdown is a task that takes a long time to process and cannot be forcibly terminated during the processing process. After taking over the system shutdown, the first application corresponding to the first task that can take over the shutdown can completely independently decide the task execution before the system shutdown. Exemplarily, the first task that can take over the shutdown can be upgrading the operating system, upgrading application software, etc. Correspondingly, the first application can be an application such as system upgrade software and application market. The operating system can only control one first application to process the corresponding first task at the same time.

[0021] In a possible implementation manner of the first aspect, the multiple target tasks include a second task whose task type is interactive, and the target application corresponding to the second task is a second application;

[0022] According to the processing order of multiple target tasks, a system shutdown notification is sent to the target application corresponding to each target task in turn, including: sending a system shutdown notification to a second application; receiving a task completion notification sent by the second application, which is sent after the second application detects the existence of a second task based on the system shutdown notification and processes the second task according to a trigger operation of the user on the interactive interface; according to the task completion notification and the processing order of multiple target tasks, a system shutdown notification is sent to a target application corresponding to the next target task of the second task.

[0023] Among them, the interactive second task is a task that requires interaction with the user, and the second application corresponding to the second task needs to process the second task based on the user's interactive operation. Therefore, if the multiple target tasks obtained include multiple second tasks, the operating system needs to control the second application to synchronously process the corresponding second tasks in sequence according to the processing order, that is, the operating system can only control one second application to process the corresponding second task at the same time, thereby improving the rationality of interaction with the user when the system is shut down.

[0024] Exemplarily, the second task may be a task of saving documents, emails, etc. that the user has not saved. Correspondingly, the second application may be a word processing software, email software, etc., such as WPS Office and Microsoft Office.

[0025] In a possible implementation manner of the first aspect, the multiple target tasks include a third task whose task type is non-interactive, and the target application corresponding to the third task is a third application;

[0026] According to the processing order of multiple target tasks, control the target application corresponding to each target task to process the target task, including: according to the processing order of multiple target tasks, at each preset time interval, simultaneously send a system shutdown notification to the third application corresponding to the third task with the same priority level, and the system shutdown notification is used to instruct the third application to process the corresponding third task within the preset time.

[0027] The third task is a lightweight task that does not require interaction with the user and has a short processing time. Therefore, the operating system can control multiple third applications to asynchronously process the corresponding third tasks at the same time, thereby improving the processing efficiency of the task and shortening the shutdown time of the electronic device. If a third application fails to complete the processing of the corresponding third task within the preset time, it does not need to continue processing the unfinished part of the third task.

[0028] Exemplarily, the third task may be a task such as data persistent storage.

[0029] In a second aspect, the present application provides a system shutdown control device, comprising: at least one unit for executing the method in any possible implementation manner of the first aspect.

[0030] In a third aspect, the present application provides an electronic device, comprising: a processor, the processor being configured to run a computer program stored in a memory to implement the method in any possible implementation manner of the first aspect.

[0031] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method in any possible implementation manner of the first aspect is implemented.

[0032] In a fifth aspect, the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the method in any possible implementation manner of the first aspect.

[0033] The technical effects of the second to fifth aspects provided in the present application can refer to the technical effects of the various possible implementation methods of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A schematic diagram of a shutdown process of an existing operating system provided in an embodiment of the present application.

[0035] Figure 2 A schematic diagram of the operating system structure of an electronic device provided in an embodiment of the present application.

[0036] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0037] Figure 4 A flowchart of a method for controlling system shutdown provided in an embodiment of the present application.

[0038] Figure 5 A schematic diagram of the processing sequence of multiple target tasks provided in an embodiment of the present application.

[0039] Figure 6 A schematic diagram of a process for controlling a target application to process a corresponding target task provided in an embodiment of the present application Figure 1 .

[0040] Figure 7 A schematic diagram of a process for controlling a target application to process a corresponding target task provided in an embodiment of the present application Figure 2 .

[0041] Figure 8 A schematic diagram of a process for controlling a target application to process a corresponding target task provided in an embodiment of the present application Figure 3 .

[0042] Fig. 9 A schematic block diagram of a system shutdown control device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0043] The technical solutions in the embodiments of the present application are described below in conjunction with the drawings and related embodiments in the embodiments of the present application. Among them, in the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "a", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear indication to the contrary in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one or more (including two). The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist; for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in a "or" relationship.

[0044] References to "one embodiment" or "some embodiments" etc. described in this specification mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Thus, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways. The term "connection" includes direct connection and indirect connection, unless otherwise specified. "First" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.

[0045] In the embodiments of the present application, the words "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a specific way.

[0046] The steps involved in the method provided in the embodiments of the present application are only examples, not all steps are steps that must be performed, or not all information or content in the message is mandatory, and can be increased or reduced as needed during use. In the embodiments of the present application, the same step or steps or messages with the same function can be referenced and learned from each other in different embodiments.

[0047] The iPhone operating system (IOS), Android, and Harmony are several commonly used mobile operating systems in electronic devices. System shutdown is a power management technology of mobile operating systems. After the user shuts down or restarts the electronic device, the operating system needs to first shut down the processes running in user mode, and then shut down the system kernel to achieve system shutdown.

[0048] For details, see Figure 1A schematic diagram of a shutdown process of an existing operating system is shown. Taking the Android system installed on an electronic device as an example, if the user triggers a shutdown operation on the electronic device, the operating system can issue a shutdown broadcast according to the shutdown operation, and the application pre-registered to receive the shutdown broadcast can process the tasks before shutdown after listening to the shutdown broadcast; then shut down various system services in a fixed order, including activity manager service (AMS), package manager service (PMS) and radios service; after completing the upper-layer shutdown process, call the bottom layer through the power management service (power manager service), and set the system property to "SystemProperties.set("sys.powerctl", "shutdown")" and then enter the bottom-level shutdown to shut down the system kernel; finally, shut down all hardware and shut down the electronic device.

[0049] There are many kinds of applications running in electronic devices, and various applications need to perform corresponding tasks before the system shuts down to prevent the loss of application data, such as saving documents edited by users, saving application or system configuration information, etc. Although some applications can complete the processing of corresponding tasks before the system shuts down by listening to the shutdown broadcast when shutting down based on the existing system shutdown method, other applications that cannot listen to the broadcast will stop running when the operating system shuts down the system service, resulting in some tasks being unable to be processed before the system shuts down.

[0050] In addition, the existing system shutdown process is fixed and lacks scalability and flexibility. If there are new tasks to be processed before shutdown, system developers are required to insert the new tasks to be processed before shutdown into the existing system shutdown process, which increases the development difficulty for system developers.

[0051] In order to solve the above problems, the embodiments of the present application provide a system shutdown control method, device, electronic device and readable storage medium. After the user triggers the shutdown operation on the electronic device, the operating system in the electronic device can first obtain all target tasks that need to be processed before the system shuts down, and determine the processing order of each type of target tasks according to the task type of the target task, and then control the target application corresponding to each target task to process its respective target task. This control method can meet the processing requirements of different types of target tasks before the system shuts down, thereby improving the flexibility of system shutdown.

[0052] The operating system involved in the system shutdown control method provided in the embodiment of the present application may be a mobile operating system such as Android, Apple or Hongmeng. Figure 2, is a schematic diagram of the operating system structure of an electronic device provided in an embodiment of the present application.

[0053] In some embodiments, the operating system of the electronic device may be divided into four layers, including a hardware layer, a kernel layer, a system service layer, and an application layer, and the layers communicate with each other through software interfaces.

[0054] like Figure 2 As shown, the hardware layer includes physical devices that provide specific interactive responses, such as speakers, sensors, WLAN, Modem, microphones, displays, and motors.

[0055] The kernel layer includes the kernel abstract layer (KAL) and the driver subsystem. KAL includes multiple kernels, such as the Linux kernel of the Linux system and the LiteOS kernel of the lightweight IoT system. The kernel layer of multiple kernels can select the corresponding kernel for processing according to the needs of the system. The driver subsystem can include the hardware driver foundation (HDF), such as audio driver, wireless local area network (WLAN) driver, modem driver, etc. The hardware driver framework can provide unified peripheral access capabilities and driver development and management framework.

[0056] The system service layer is the core capability set of the operating system. The system service layer provides services to applications through the framework layer. This layer can include the system basic capability subsystem set, the basic software service subsystem set, the enhanced software service subsystem set, and the hardware service subsystem set.

[0057] The system basic capability subsystem set provides basic capabilities for the operation, scheduling, migration and other operations of distributed applications on the devices of the operating system. It may include subsystems such as distributed soft bus, distributed data management, distributed task scheduling, Ark multi-language runtime, public basic library, multi-mode input, graphics, security, artificial intelligence (AI), user program framework, etc. Among them, the Ark multi-language runtime provides C or C++ or JavaScript (JS) multi-language runtime and basic system class libraries, and can also provide runtime for Java programs statically compiled using the Ark compiler (i.e., the part developed in Java language in the application or framework layer).

[0058] The basic software service subsystem provides common and general software services for the operating system, including download services, multimedia services, power services, telephone services, etc.

[0059] The enhanced software service subsystem set provides the operating system with differentiated capability-enhanced software services for different devices, including smart screen proprietary services, wearable proprietary services, and Internet of Things (IoT) proprietary service subsystems.

[0060] The hardware service subsystem provides hardware services for the operating system, including location services, biometric recognition, wearable proprietary hardware services, IoT proprietary hardware services, and other subsystems.

[0061] The application layer includes system applications and third-party applications (or extended applications). System applications may include applications installed by default on electronic devices such as the desktop, control bar, settings, and phone. Extended applications can be non-essential applications developed and designed by the manufacturer of the electronic device, such as electronic device managers, device migration, notes, weather, browsers, and other applications. Third-party non-system applications can be developed by other manufacturers but can run applications in the operating system, such as conference, game, navigation, social, shopping, music, and other applications.

[0062] Multiple electronic devices running operating systems can achieve hardware mutual assistance and resource sharing through distributed soft buses, distributed device virtualization, distributed data management and distributed task scheduling.

[0063] The electronic devices involved in the system shutdown control method provided in the embodiment of the present application are mobile phones, tablet computers, wearable devices, and other devices that can be installed with mobile operating systems such as Android, Apple, or Hongmeng systems. The embodiment of the present application does not impose any restrictions on the specific type of electronic devices.

[0064] Next, the electronic device involved in the embodiment of the present application is introduced. Figure 3 , Figure 3 A schematic structural diagram of an electronic device 300 is shown.

[0065] The electronic device 300 may include a processor 310, an external memory interface 320, an internal memory 321, a universal serial bus (USB) interface 330, a charging management module 340, a power management module 341, a battery 342, an antenna 1, an antenna 2, a mobile communication module 350, a wireless communication module 360, a sensor module 370, a button 380, and a display screen 390, etc. Among them, the sensor module 370 may include a pressure sensor 370A, a gyroscope sensor 370B, an acceleration sensor 370C, a temperature sensor 370D, a touch sensor 370E, and the like.

[0066] The processor 310 may include one or more processing units, for example, the processor 310 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0067] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

[0068] The processor 310 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 310 is a cache memory. The memory may store instructions or data that the processor 310 has just used or cyclically used. If the processor 310 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 310, and thus improves the efficiency of the system.

[0069] In some embodiments, the processor 310 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0070] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 310 may include multiple groups of I2C buses. The processor 310 may be coupled to the touch sensor 370E, the charger, etc. through different I2C bus interfaces. For example, the processor 310 may be coupled to the touch sensor 370E through the I2C interface, so that the processor 310 communicates with the touch sensor 370E through the I2C bus interface to realize the touch function of the electronic device 300.

[0071] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 310 and the wireless communication module 360. For example: the processor 310 communicates with the Bluetooth module in the wireless communication module 360 ​​through the UART interface to realize the Bluetooth function. The MIPI interface can be used to connect the processor 310 to peripheral devices such as the display screen 390. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 310 and the display screen 390 communicate through the DSI interface to realize the display function of the electronic device 300.

[0072] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 310 with the display screen 390, the wireless communication module 360, the sensor module 370, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0073] The USB interface 330 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 330 can be used to connect a charger to charge the electronic device 300, and can also be used to transfer data between the electronic device 300 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.

[0074] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 300. In other embodiments of the present application, the electronic device 300 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0075] The charging management module 340 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 340 may receive charging input from a wired charger through the USB interface 330. In some wireless charging embodiments, the charging management module 340 may receive wireless charging input through a wireless charging coil of the electronic device 300. While the charging management module 340 is charging the battery 342, it may also power the electronic device through the power management module 341.

[0076] The power management module 341 is used to connect the battery 342, the charging management module 340 and the processor 310. The power management module 341 receives input from the battery 342 and / or the charging management module 340, and supplies power to the processor 310, the internal memory 321, the display screen 390, and the wireless communication module 360. The power management module 341 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 341 can also be set in the processor 310. In other embodiments, the power management module 341 and the charging management module 340 can also be set in the same device.

[0077] The wireless communication function of the electronic device 300 can be implemented through the antenna 1, the antenna 2, the mobile communication module 350, the wireless communication module 360, the modem processor and the baseband processor.

[0078] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 300 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0079] The mobile communication module 350 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 300. The mobile communication module 350 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 350 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 350 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 350 can be set in the processor 310. In some embodiments, at least some of the functional modules of the mobile communication module 350 can be set in the same device as at least some of the modules of the processor 310.

[0080] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor displays an image or video through the display screen 390. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 310 and be set in the same device as the mobile communication module 350 or other functional modules.

[0081] The wireless communication module 360 ​​can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 300. The wireless communication module 360 ​​can be one or more devices integrating at least one communication processing module. The wireless communication module 360 ​​receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 310. The wireless communication module 360 ​​can also receive the signal to be sent from the processor 310, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0082] In some embodiments, the antenna 1 of the electronic device 300 is coupled to the mobile communication module 350, and the antenna 2 is coupled to the wireless communication module 360, so that the electronic device 300 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

[0083] The electronic device 300 implements the display function through a GPU, a display screen 390, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 390 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 310 may include one or more GPUs, which execute program instructions to generate or change display information.

[0084] The display screen 390 is used to display images, videos, etc. The display screen 390 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode or an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 300 may include 1 or N display screens 390, where N is a positive integer greater than 1.

[0085] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 300 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0086] Video codecs are used to compress or decompress digital videos. The electronic device 300 may support one or more video codecs. Thus, the electronic device 300 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0087] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 300 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0088] The external memory interface 320 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 300. The external memory card communicates with the processor 310 through the external memory interface 320 to implement a data storage function, such as saving files such as videos in the external memory card.

[0089] The internal memory 321 can be used to store computer executable program codes, which include instructions. The internal memory 321 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, at least one application required for a function (such as an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 300 (such as a phone book, etc.), etc. In addition, the internal memory 321 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 310 executes various functional applications and data processing of the electronic device 300 by running instructions stored in the internal memory 321 and / or instructions stored in a memory provided in the processor.

[0090] The pressure sensor 370A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 370A can be set on the display screen 390. There are many types of pressure sensors 370A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 370A, the capacitance between the electrodes changes. The electronic device 300 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 390, the electronic device 300 detects the touch operation intensity according to the pressure sensor 370A. The electronic device 300 can also calculate the touch position according to the detection signal of the pressure sensor 370A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.

[0091] The gyro sensor 370B can be used to determine the motion posture of the electronic device 300. In some embodiments, the angular velocity of the electronic device 300 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 370B. The gyro sensor 370B can be used for navigation and somatosensory game scenes.

[0092] The acceleration sensor 370C can detect the magnitude of the acceleration of the electronic device 300 in all directions (generally three axes). When the electronic device 300 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.

[0093] The temperature sensor 370D is used to detect temperature. In some embodiments, the electronic device 300 uses the temperature detected by the temperature sensor 370D to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 370D exceeds a threshold, the electronic device 300 reduces the performance of the processor located near the temperature sensor 370D to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 300 heats the battery 342 to avoid abnormal shutdown of the electronic device 300 due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 300 performs a boost on the output voltage of the battery 342 to avoid abnormal shutdown caused by low temperature.

[0094] The touch sensor 370E is also called a "touch control device". The touch sensor 370E can be set on the display screen 390, and the touch sensor 370E and the display screen 390 form a touch screen, also called a "touch control screen". The touch sensor 370E is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 390. In other embodiments, the touch sensor 370E can also be set on the surface of the electronic device 300, which is different from the position of the display screen 390.

[0095] The key 380 includes a power key, a volume key, etc. The key 380 may be a mechanical key or a touch key. The electronic device 300 may receive key input and generate key signal input related to user settings and function control of the electronic device 300.

[0096] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 300. In other embodiments of the present application, the electronic device 300 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0097] Next, the system shutdown control method provided in the embodiment of the present application is introduced. Figure 4 It is a flow chart of a method for controlling system shutdown provided in an embodiment of the present application. The method can be applied to the above-mentioned electronic device installed with a mobile operating system. The method includes steps S410 to S440. Each step is described in detail below.

[0098] S410 , in response to a shutdown operation, obtaining a plurality of target tasks to be processed before the system is shut down and a task type of each target task.

[0099] In the embodiment of the present application, the triggering condition of the shutdown operation may be the automatic shutdown of the electronic device due to insufficient power, the forced shutdown of the electronic device by the user, the automatic shutdown of the electronic device at a preset time, or the shutdown caused by the restart of the electronic device, etc. Exemplarily, when the user forces the shutdown, the user triggers a single mechanical button on the electronic device (for example, pressing the power button for a preset time), or triggers multiple mechanical buttons on the electronic device (for example, pressing the power button and the volume button at the same time for a preset time), and triggers the shutdown button in the prompt information displayed on the display screen of the electronic device, which can trigger the shutdown operation of the electronic device.

[0100] It should be noted that after the user triggers the shutdown operation on the electronic device, the operating system of the electronic device may obtain a target task that needs to be processed before the system is shut down, or may obtain multiple target tasks that need to be processed before the system is shut down. The multiple target tasks obtained by the operating system may include multiple tasks that need to be processed by a target application running in the electronic device before the system is shut down, and / or multiple different tasks that need to be processed by multiple different target applications running in the electronic device before the system is shut down.

[0101] Exemplarily, the target application can be system software installed on the electronic device, such as operating system software, language processing system software, database management system software, memo, etc.; the target application can also be third-party software installed on the electronic device, such as word processing software such as WPS Office, Microsoft Office, email software, etc.

[0102] In the present application, the application software installed in the electronic device can communicate with the operating system of the electronic device through a software development kit (SDK) interface, wherein the SDK is developed based on the operating system of the electronic device, and is specifically a collection of development tools for software engineers to create application software for specific software packages, software frameworks, hardware platforms, and operating systems. It can be simple files that provide application program interfaces for a certain programming language, but may also include complex hardware that can communicate with a certain embedded system.

[0103] After the target application installed in the electronic device is started and running, it can actively send one or more target tasks that the target application itself needs to process before the system shuts down, as well as the task type of each target task, to the operating system through the SDK interface, so that after the operating system detects that the user triggers the shutdown operation, it can control each target application to process the corresponding target task before the system shuts down.

[0104] Exemplarily, the target task may be a system upgrade task of an operating system software, a data persistence storage task of a database management system software, a document preservation task of a word processing software, and the like.

[0105] In one embodiment, the task type of the task to be processed is related to the function of the corresponding application and the task processing method. Based on the application corresponding to the task to be processed and the task processing method, the multiple target tasks to be processed before the system is shut down can be divided into three categories. Specifically, the first category of target tasks can include one or more first tasks whose task type is to take over the shutdown, the second category of target tasks can include one or more second tasks whose task type is interactive, and the third category of target tasks can include one or more third tasks whose task type is non-interactive.

[0106] The first task that can take over the shutdown is a task that takes a long time to process and cannot be forcibly terminated during the process, and the target application corresponding to the first task is the first application. For example, the first application can be system upgrade software, application market and other applications, and accordingly, the first task can be upgrading the operating system, upgrading application software, etc. If the operating system and application software are forcibly terminated during the upgrade process, the operating system and application may be damaged.

[0107] The interactive second task is a task that needs to interact with the user, the target application corresponding to the second task is the second application, the second application needs to process the corresponding second task according to the user's interactive instructions, and the operating system can control each second application in turn to synchronously process the corresponding second task. Exemplarily, the second application can be a word processing software such as WPS Office, Microsoft Office, or a mailbox software, and correspondingly, the second task can be a task such as saving a user's unsaved documents or saving a user's unsaved emails.

[0108] The non-interactive third task is a lightweight task that does not require interaction with the user and has a short processing time. The target application corresponding to the third task is a third application. The operating system can control multiple third applications to asynchronously process the corresponding third tasks at the same time. For example, the third application can be data persistence service software, etc., and accordingly, the third task can be data persistence storage, etc.

[0109] It should be noted that the classification method of the task type of the target task and the number of task types in the embodiment of the present application are merely exemplary and do not constitute a specific limitation on the different task types of the target task. The task types of the target task can be divided based on other classification methods.

[0110] S420: Determine a processing order of the multiple target tasks according to the task type of each target task.

[0111] In one embodiment, if the task types of multiple target tasks acquired by the operating system of the electronic device are all different, all target tasks may be sorted according to the correspondence between preset task types and processing orders to obtain the processing order of the multiple target tasks.

[0112] Exemplarily, the target task may be processed in a preset processing order of a task type that can take over shutdown, an interactive task type, and a non-interactive task type.

[0113] In other embodiments, if the multiple target tasks acquired by the operating system of the electronic device include multiple target tasks with the same task type, the operating system can also obtain the priority level of each target task to further sort the processing order of the multiple target tasks with the same task type according to the priority level of the target task.

[0114] Specifically, the operating system of the electronic device can sort the multiple target tasks acquired according to the correspondence between the task type and the processing order of the preset tasks to obtain a first sorting result; adjust the order of the target tasks with the same task type in the first sorting result according to the priority level of each target task to obtain a second sorting result; and determine the processing order of the multiple target tasks based on the second sorting result.

[0115] Among them, the priority level of the target task includes at least two. When the task types of multiple target tasks are the same, the operating system can give priority to controlling the target application corresponding to the target task with a higher priority to process the target task. In one example, the priority level of the target task can be determined by the operating system according to the type of the target application corresponding to the target task. For example, the type of the target application corresponding to the target task is a third-party software installed on the electronic device or a system-provided software. Accordingly, the priority level of the target task can include two, and the priority level of the target task corresponding to the system-provided software is higher than the priority level of the target task corresponding to the third-party application.

[0116] In another example, when each target application sends the corresponding target task to the operating system, it can also send the priority level of the corresponding target task to the operating system. For example, the priority level of the target task can include three, and the three priority levels are arranged in descending order as the first priority level, the second priority level, and the third priority level.

[0117] As an example but not a limitation, assuming that the multiple target tasks acquired by the operating system include multiple first tasks of a task type that can take over shutdown, multiple second tasks of an interactive task type, and multiple third tasks of a non-interactive task type, and the target tasks of each task type include at least one target task with a first priority level, at least one target task with a second priority level, and at least one target task with a third priority level, then the processing order of the multiple target tasks acquired by the operating system can be as follows: Figure 5 See Figure 5 , the processing order of multiple target tasks is: the first task whose task type is takeover shutdown and has a first priority level, the first task whose task type is takeover shutdown and has a second priority level, the first task whose task type is takeover shutdown and has a third priority level, the second task whose task type is interactive and has a first priority level, the second task whose task type is interactive and has a second priority level, the second task whose task type is interactive and has a third priority level, the third task whose task type is non-interactive and has a first priority level, the third task whose task type is non-interactive and has a second priority level, and the third task whose task type is non-interactive and has a third priority level.

[0118] It should be noted that the embodiment of the present application does not specifically limit the specific number of priority levels of the task. In other embodiments of the present application, the number of priority levels of the target task can be greater than three.

[0119] Furthermore, in other embodiments, if there are at least two target tasks with the same task type and priority among all the target tasks acquired by the operating system, the operating system can also obtain the generation time of each target task, and adjust the order of multiple target tasks with the same priority and the same task type in the above-mentioned second sorting result according to the generation time of each target task, so as to further determine the processing order of all target tasks.

[0120] The generation time of the target task may be the specific time when the operating system receives the corresponding target task sent by the target application. In the case where there are multiple target tasks with the same task type and priority, the operating system may determine the processing order of multiple target tasks with the same task type and priority among all the acquired target tasks in the order of their generation time from earliest to latest, thereby giving priority to controlling the target application corresponding to the target task with an earlier generation time to process the target task.

[0121] Optionally, if among all the target tasks acquired by the operating system, there are at least two target tasks with the same task type, priority and generation time, the operating system can randomly sort the at least two target tasks with the same priority, task type and generation time in the above second sorting result.

[0122] S430, controlling a target application corresponding to each target task to process the target task according to the processing order of the multiple target tasks.

[0123] In this step, the operating system controls the target application corresponding to the target task of each task type to process the target task differently. Specifically, for at least one task type among the multiple target tasks acquired by the operating system is a first task that can take over the shutdown, the first application corresponding to the first task can be controlled to process the first task in the following manner one. For at least one task type among the multiple target tasks acquired by the operating system is an interactive second task, the second application corresponding to the second task can be controlled to process the second task in the following manner two. For at least one task type among the multiple target tasks acquired by the operating system is a non-interactive third task, the third application corresponding to the third task can be controlled to process the third task in the following manner three.

[0124] The following specifically describes the process in which the operating system controls the target application corresponding to the target task of different task types to process the target task through different implementation methods in conjunction with the corresponding flow chart.

[0125] Method 1

[0126] For one or more of the multiple target tasks acquired by the operating system, whose task type is a first task that can take over shutdown, the operating system can send a system shutdown notification to the first application corresponding to each first task in turn according to the processing order of the first tasks. The system shutdown notification can be used to instruct the first application to process the corresponding first task.

[0127] In one implementation, see Figure 6 The process diagram of controlling the target application to process the corresponding target task is shown in FIG. Figure 1 , the operating system can Figure 6 The steps in the control control any first application to process the corresponding first task. Each step is described in detail below.

[0128] S610: The operating system sends a system shutdown notification to the first application.

[0129] S620: The first application determines whether to continue processing the first task according to the system shutdown notification.

[0130] It should be noted that the first application installed in the electronic device can send the first task to be processed before the system is shut down to the operating system after it is started. Therefore, there may be a situation where the first application has already processed the first task when the user triggers the shutdown operation of the electronic device, and there may also be a situation where the first application has not completed the first task when the user triggers the shutdown operation of the electronic device. Therefore, after receiving the system shutdown notification sent by the operating system, the first application needs to determine whether the first task has been processed and whether the first task needs to be continued if it has not been processed.

[0131] S630: If the first application determines to continue processing the first task, it sends a shutdown takeover notification to the operating system.

[0132] When the user triggers the shutdown operation of the electronic device and the first application has not completed processing the first task, the first application can determine that it needs to continue processing the first task based on the system shutdown notification. Accordingly, the first application can send a shutdown takeover notification to the operating system after determining that it needs to continue processing the first task, and continue processing the first task, wherein the shutdown takeover notification can be used to indicate that the first application needs to continue processing the first task and take over the system shutdown.

[0133] S640: The operating system suspends system shutdown according to the shutdown takeover notification.

[0134] In another implementation, after the operating system suspends the system shutdown, it is necessary to restart the system shutdown process after the first application completes processing the corresponding first task, so as to control other target applications to process the corresponding target tasks. Therefore, after the above step S640, the method for the operating system to control the first application to process the corresponding first task also includes the following steps S650 and S660.

[0135] S650: After processing the first task, the first application sends a task completion notification to the operating system.

[0136] S660: The operating system sends a system shutdown notification to a target application corresponding to a next target task of the first task according to the task completion notification and the processing order of the multiple target tasks.

[0137] Among them, according to the processing order of all target tasks acquired by the operating system, the next target task of the first task can be the next first task whose generation time is the same as the generation time of the currently processed first task and has the same priority level, or the next first task whose generation time is later than the generation time of the currently processed first task and has the same priority level, or the first task with the next priority level, or the second task, or the third task.

[0138] It is understandable that, in method 1, when the user triggers the shutdown operation of the electronic device and the first application has already processed the first task, the first application can determine that it does not need to continue processing the first task based on the system shutdown notification, and the first application can send a non-takeover notification to the operating system, and the non-takeover notification can be used to instruct the first application not to continue processing the first task and not to take over the system shutdown. After receiving the non-takeover notification, the operating system can send a system shutdown notification to the target application corresponding to the next target task of the first task according to the processing order of the multiple target tasks determined in the above embodiment, so as to instruct the target application corresponding to the next target task to process the target task.

[0139] Method 2

[0140] For one or more interactive second tasks among the multiple target tasks acquired by the operating system, the operating system can perform synchronous processing on the second tasks according to the processing order of the second tasks. Specifically, a system shutdown notification can be sent to the second application corresponding to each second task in turn. The system shutdown notification can be used to instruct the second application to process the corresponding first task.

[0141] In one implementation, see Figure 7 A schematic diagram of a process of controlling a target application to process a corresponding target task Figure 2 , the operating system can Figure 7 The steps in the control control any second application to process the corresponding second task. Each step is described in detail below.

[0142] S710: The operating system sends a system shutdown notification to the second application.

[0143] S720: The second application detects whether a second task exists according to the system shutdown notification.

[0144] It should be noted that the second task is a task that the second application needs to process according to the user's interactive instructions, and the second application installed in the electronic device can send the second task that may need to be processed before the system is shut down to the operating system after it is started. Therefore, when the user triggers the shutdown operation of the electronic device, the second application may have processed the corresponding second task according to the user's interactive instructions; or when the user triggers the shutdown operation of the electronic device, the second application does not detect the user's interactive instructions and does not process the second task. Therefore, after receiving the system shutdown notification sent by the operating system, the second application can first detect whether there is a second task to be processed.

[0145] S730: If the second application detects the existence of the second task, it displays an interactive interface and processes the second task according to a triggering operation of the user on the interactive interface.

[0146] Specifically, if the second application detects that there is a second task to be processed based on the system shutdown notification, an interactive interface can be displayed in the display interface of the electronic device, and the second task can be processed according to the processing method indicated by the user's trigger operation on the interactive interface.

[0147] As an example but not limitation, assume that the second task is to save a word document that has not been saved by the user, and the second application is WPS Office. If WPS Office detects that there is a first word document in an editing state that has not been saved after receiving the system shutdown notification sent by the operating system, an interactive interface is displayed in the display interface of the electronic device. The interactive interface displays a prompt message "Do you want to save changes to the first word document", a "Yes" button and a "No" button. If the user triggers the "Yes" button, the second application can save the first word document to the preset storage space. If the user triggers the "No" button, the second application does not save the first word document.

[0148] It should be noted that if the second application does not detect the user's trigger operation on the interactive interface, the corresponding second task cannot be processed, thereby blocking the system shutdown process of the operating system. The operating system can only continue to execute the next target task after the second application detects the user's trigger operation and processes the second task.

[0149] In another implementation, the operating system needs to continue executing the system shutdown process after the second application completes processing the corresponding second task. Therefore, after the above step S730, the method for the operating system to control the second application to process the corresponding second task also includes the following steps S740 and S750.

[0150] S740: After processing the second task, the second application sends a task completion notification to the operating system.

[0151] S750: The operating system sends a system shutdown notification to a target application corresponding to a next target task of the second task according to the task completion notification and the processing order of the multiple target tasks.

[0152] Among them, the next target task of the second task can be the next second task whose generation time is the same as the generation time of the currently processed second task and has the same priority level, or the next second task whose generation time is later than the generation time of the currently processed second task and has the same priority level, or the second task with the next priority level, or the third task.

[0153] It can be understood that in method two, if the second application detects that there is no second task to be processed based on the system shutdown notification, the second application can send a notification to the operating system to instruct the operating system to continue executing the system shutdown process, so that the operating system can send a system shutdown notification to the target application corresponding to the next target task of the second task according to the processing order of multiple target tasks.

[0154] Method 3

[0155] The non-interactive third task is a lightweight task that does not require interaction with the user and has a short processing time. Therefore, the operating system can control multiple third applications at the same time to asynchronously process the corresponding third tasks, thereby improving the task processing efficiency and shortening the shutdown time of the electronic device.

[0156] In one implementation, the operating system may send a system shutdown notification to the third application corresponding to the third task with the same priority level at a preset time interval according to the processing order of the multiple target tasks, and the system shutdown notification is used to instruct the third application to process the corresponding third task within the preset time. In order to improve the processing efficiency of the task, the preset time should not be too long, and by way of example, the preset time may be 30 seconds.

[0157] By way of example and not limitation, see Figure 8 A schematic diagram of a process of controlling a target application to process a corresponding target task Figure 3 , assuming that the multiple target tasks acquired by the operating system include multiple third tasks of non-interactive task type, and the multiple third tasks include at least one third task with a first priority level, at least one third task with a second priority level, and at least one third task with a third priority level ( Figure 8 Only multiple third applications corresponding to the third tasks of each priority level are shown in the figure), the operating system can determine the processing order of the third tasks according to the priority level of the target task, which is all the third tasks with the first priority level, all the third tasks with the second priority level, and all the third tasks with the third priority level among the multiple target tasks obtained.

[0158] Based on this, the operating system can follow the processing order by Figure 8 Steps S810 to S860 in the embodiment control the third application corresponding to all the third tasks in the acquired multiple target tasks to process the corresponding third tasks, and each step is specifically as follows:

[0159] S810, the operating system simultaneously sends a system shutdown notification to all third applications corresponding to the third tasks having the first priority level.

[0160] S820: The third application corresponding to the third task with the first priority level processes the corresponding third task within a preset time period according to the system shutdown notification.

[0161] S830: After a preset time period, the operating system simultaneously sends a system shutdown notification to all third applications corresponding to the third tasks with the second priority level.

[0162] The preset interval duration refers to the time interval between the current moment and the moment when the system shutdown notification is sent to the third application corresponding to the third task with the first priority level.

[0163] S840: The third application corresponding to the third task with the second priority level processes the corresponding third task within a preset time period according to the system shutdown notification.

[0164] S850: After a preset time interval, the operating system sends a system shutdown notification to all third applications corresponding to the third tasks with the third priority level at the same time.

[0165] The so-called preset interval again refers to the time interval between the current moment and the moment when the system shutdown notification is sent to the third application corresponding to the third task with the second priority level.

[0166] S860: The third application corresponding to the third task with the third priority level processes the corresponding third task within a preset time period according to the system shutdown notification.

[0167] It should be noted that, in the process of the operating system controlling the third application to process the corresponding third task, the third application does not need to send a task completion notification to the operating system, and each third application can asynchronously process the corresponding third task in an independently running thread. If there is a third application that has not completed processing the corresponding third task within the preset time, the unfinished third task can be discarded (that is, the corresponding thread stops running), and the operating system will send a system shutdown notification to all third applications corresponding to the third tasks with the next priority level at the same time after the preset time interval from the last time the system shutdown notification was sent to the third application, according to the processing order of the target task determined in the above embodiment, until all third applications are controlled to complete processing the corresponding third tasks.

[0168] Based on the above three different methods, the operating system can obtain all target tasks that need to be processed before the system shuts down, and determine the processing order of all target tasks according to the task type, priority level and generation time of the task. Before the system shuts down, the operating system can control the corresponding target applications to process target tasks of different task types according to the determined processing order using different processing methods. The above control method can meet the processing requirements of pending tasks of different task types before the system shuts down, and can improve the flexibility of processing target tasks of different task types before the system shuts down.

[0169] In addition, it should be noted that in the method provided in the embodiment of the present application, the multiple target tasks acquired by the operating system may include tasks of one or more different task types, each task type may include tasks with one or more different priority levels, and tasks of the same priority level may include one or more tasks with different generation times. That is to say, the multiple target tasks acquired by the operating system may not completely include tasks of all task types and all priority levels. In this case, the operating system does not need to completely follow the system shutdown procedure before the system is shut down. Figure 5 The fixed processing flow shown in processes tasks of all task types, all priority levels, and all generation times.

[0170] Exemplarily, assume that the multiple target tasks acquired by the operating system include a second task 1 and a second task 2 having a first priority level and an interactive task type, a third task 1 and a third task 2 having a first priority level and a non-interactive task type, and a third task 3 having a second priority level and a non-interactive task type, wherein the generation time of the first task 1 is earlier than the generation time of the second task 2. Based on this, the operating system can determine, according to the task types and priorities of the multiple target tasks, that the processing order of the multiple target tasks is second task 1, second task 2, third task 1 and third task 2 that need to be processed simultaneously, and third task 3.

[0171] Among them, the second task 1 and the second task 2 can use the method of steps S710 to S750 in the above-mentioned method 2 to control the corresponding second application to process in sequence. After the second task 3 is processed, the operating system can simultaneously send a system shutdown notification to the third application 1 corresponding to the third task 1 and the third application 2 corresponding to the third task 2, so as to instruct the third application 1 and the third application 2 to process the third task 1 and the third task 2 respectively within a preset time. After an interval of a preset time, the operating system can send a system shutdown notification to the third application 3 corresponding to the third task 3, so as to instruct the third application 3 to process the third task 3 within a preset time.

[0172] S440, shutting down the control system after the processing of the plurality of target tasks is completed.

[0173] In one embodiment, if the last target task processed among multiple target tasks obtained by the operating system is a first task that can take over the shutdown or an interactive second task, the operating system can consider that all target tasks have been processed after obtaining the task completion notification sent by the target application corresponding to the last target task processed.

[0174] In other embodiments, if the last target task processed among multiple target tasks acquired by the operating system is a non-interactive third task, the operating system can consider that all target tasks have been processed after a preset time interval from the time when the system shutdown notification was last sent to the third application corresponding to the third task.

[0175] After the operating system determines that all acquired target tasks have been processed, the subsequent system shutdown process can be executed according to the shutdown operation triggered by the user on the electronic device. Exemplarily, if the shutdown operation is used to indicate restarting the electronic device, the subsequent system shutdown process may include shutting down various system services, shutting down the system kernel, restarting the system kernel, and restarting various system services, wherein the various system services include but are not limited to activity management services, package management services, and radio frequency services. If the shutdown operation is used to indicate shutting down the electronic device, the subsequent system shutdown process may include shutting down various system services, shutting down the system kernel, and powering off all hardware in the electronic device.

[0176] Based on the system shutdown control method provided in the above-mentioned embodiment of the present application, for all target tasks to be processed of different task types and application scenarios before system shutdown, three different processing methods, namely takeover shutdown processing, synchronous processing and asynchronous processing, are set for target tasks of different task types. Before the system is shut down, the operating system can first determine the processing order of all target tasks based on the task type, priority level and generation time of the target tasks, and then control the target application to process the corresponding target tasks in accordance with the processing order and using the processing method corresponding to the task type of each target task, and then execute the subsequent system shutdown process. This can effectively avoid the loss or damage of application data and system data. This control method is suitable for the processing requirements of different types of tasks to be processed before shutdown, and improves the flexibility of system shutdown.

[0177] The above describes the method embodiment provided by the present application, and the following describes the device embodiment provided by the present application. It should be understood that the description of the device embodiment corresponds to the description of the method embodiment, so the content not described in detail can be referred to the method embodiment above, and for the sake of brevity, it will not be repeated here.

[0178] Fig. 9 is a schematic block diagram of a control device for system shutdown provided in an embodiment of the present application. Fig. 9 As shown, the control device 900 for system shutdown may include a processing unit 910 and a communication unit 920. The communication unit 920 may implement a corresponding communication function, and the communication may be an internal communication of the control device 900 for system shutdown or a communication between the control device 900 for system shutdown and other devices; the processing unit 910 may implement a corresponding processing function. The communication unit 920 may also be referred to as a communication interface or a transceiver unit. Optionally, the control device 900 for system shutdown may also include a storage unit, which may be used to store instructions and / or data, and the processing unit 910 may read the instructions and / or data in the storage unit, so that the device implements the aforementioned method embodiment.

[0179] In a possible design, the system shutdown control device 900 can be a module or chip applied to an electronic device. The system shutdown control device 900 can be used to execute the steps or processes executed by the electronic device in the above-mentioned various embodiments.

[0180] Specifically, the communication unit 920 is used to respond to the shutdown operation and obtain multiple target tasks to be processed before the system is shut down and the task type of each target task. The processing unit 910 is used to determine the processing order of multiple target tasks according to the task type of each target task; according to the processing order of multiple target tasks, control the target application corresponding to each target task to process the target task; and control the system to shut down after the multiple target tasks are processed.

[0181] Optionally, the communication unit 920 is further used to obtain the priority of each target task. The processing unit 910 is further used to sort the multiple target tasks according to the correspondence between the preset task type and the processing order to obtain a first sorting result; according to the priority of each target task, adjust the order of the target tasks with the same task type in the first sorting result to obtain a second sorting result; and determine the processing order of the multiple target tasks based on the second sorting result.

[0182] Optionally, the communication unit 920 is further used to obtain the generation time of each target task. The processing unit 910 is further used to adjust the order of target tasks with the same priority level and the same task type in the second sorting result according to the generation time of each target task to obtain the processing order of multiple target tasks.

[0183] Optionally, the communication unit 920 is further specifically configured to send a system shutdown notification to a target application corresponding to each target task in sequence according to a processing order of the multiple target tasks, wherein the system shutdown notification is used to instruct the target application to process the corresponding target task.

[0184] Optionally, the multiple target tasks include a first task whose task type is a takeoverable shutdown task, and the target application corresponding to the first task is the first application; the communication unit 920 is specifically used to send a system shutdown notification to the first application; receive a shutdown takeover notification sent by the first application, and the shutdown takeover notification is used to instruct the first application to continue processing the first task according to the system shutdown notification. The processing unit 910 is also used to suspend the system shutdown according to the shutdown takeover notification. The communication unit 920 is also used to receive a task completion notification sent by the first application; according to the task completion notification and the processing order of the multiple target tasks, send a system shutdown notification to the target application corresponding to the next target task of the first task.

[0185] In a possible implementation of the first aspect, the multiple target tasks include a second task whose task type is interactive, and the target application corresponding to the second task is the second application; the communication unit 920 is also specifically used to send a system shutdown notification to the second application; receive a task completion notification sent by the second application, which is sent by the second application after the second application detects the existence of the second task based on the system shutdown notification and processes the second task according to a trigger operation of the user on the interactive interface; and send a system shutdown notification to the target application corresponding to the next target task of the second task according to the task completion notification and the processing order of the multiple target tasks.

[0186] In a possible implementation of the first aspect, the multiple target tasks include a third task of a non-interactive task type, and the target application corresponding to the third task is a third application; the communication unit 920 is also specifically used to send a system shutdown notification to the third application corresponding to the third task with the same priority level at intervals of a preset time according to the processing order of the multiple target tasks, and the system shutdown notification is used to instruct the third application to process the corresponding third task within the preset time.

[0187] It should be understood that the description of the device embodiment can refer to the relevant description of the above-mentioned embodiments of the system shutdown control method. Its implementation principle and technical effect are similar to those of the above-mentioned method embodiment and will not be repeated here.

[0188] It should be understood that the "unit" in the device 900 can be implemented by hardware, can be implemented by software, and can also be implemented by hardware executing the corresponding software. For example, the "unit" can refer to an application specific integrated circuit (ASIC), an electronic circuit, a processor (such as a shared processor, a dedicated processor or a group processor, etc.) and a memory for executing one or more software or firmware programs, a combined logic circuit and / or other suitable components that support the described functions. For another example, the communication unit 920 can be replaced by a transceiver transceiver circuit (for example, it can include a receiving circuit and a transmitting circuit), and the processing unit 910 can be replaced by a processor or a processing circuit.

[0189] Based on the methods provided in the above embodiments, the embodiments of the present application also provide the following contents:

[0190] An embodiment of the present application provides a computer program product, which includes: a computer program code, when the computer program code is run on a computer, the computer is caused to execute each step or process in any of the above method embodiments.

[0191] An embodiment of the present application provides a computer-readable storage medium, which stores program code. When the program code runs on a computer, the computer executes each step or process in any of the above method embodiments.

[0192] An embodiment of the present application provides a chip, which includes a memory and a processor. The processor executes a computer program stored in the memory to implement the control method of controlling the above-mentioned electronic device to execute the system shutdown shown in the above-mentioned embodiments.

[0193] It should be understood that the processor mentioned in the embodiments of the present application may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0194] It should also be understood that the memory mentioned in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (doubledatarate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (synchlink DRAM, SLDRAM), and direct rambus RAM (DR RAM).

[0195] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. In the above embodiments, the description of each embodiment has its own emphasis. For the part that is not described or recorded in detail in a certain embodiment, refer to the relevant description of other embodiments.

[0196] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0197] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0198] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0199] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0200] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include at least: any entity or device that can carry the computer program code to a large-screen device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0201] Finally, it should be noted that the above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for controlling system shutdown, It is characterized in that The method comprises: In response to a shutdown operation, obtaining a plurality of target tasks to be processed before the system is shut down and a task type of each target task; Determining a processing order of the plurality of target tasks according to a task type of each target task; According to the processing order of the multiple target tasks, controlling the target application corresponding to each target task to process the target task; The control system is shut down after the processing of the plurality of target tasks is completed.

2. The method according to claim 1, It is characterized in that The method further comprises: obtaining a priority level of each target task; The step of determining the processing order of the plurality of target tasks according to the task type of each target task includes: Sorting the plurality of target tasks according to a correspondence between preset task types and processing orders to obtain a first sorting result; According to the priority level of each target task, the order of the target tasks with the same task type in the first sorting result is adjusted to obtain a second sorting result; The processing order of the plurality of target tasks is determined based on the second sorting result.

3. The method according to claim 2, It is characterized in that The determining the processing order of the plurality of target tasks based on the second sorting result includes: Get the generation time of each target task; According to the generation time of each target task, the order of the target tasks with the same priority level and the same task type in the second sorting result is adjusted to obtain the processing order of the multiple target tasks.

4. The method according to any one of claims 1 to 3, It is characterized in that The step of controlling the target application corresponding to each target task to process the target task according to the processing order of the multiple target tasks includes: According to the processing order of the multiple target tasks, a system shutdown notification is sent to the target application corresponding to each target task in turn, and the system shutdown notification is used to instruct the target application to process the corresponding target task.

5. The method according to claim 4, It is characterized in that The multiple target tasks include a first task whose task type is capable of taking over shutdown, and the target application corresponding to the first task is a first application; The sending of the system shutdown notification to the target application corresponding to each target task in sequence according to the processing order of the multiple target tasks includes: Sending the system shutdown notification to the first application; receiving a shutdown takeover notification sent by the first application, wherein the shutdown takeover notification is used to instruct the first application to confirm to continue processing the first task according to the system shutdown notification; suspending system shutdown according to the shutdown takeover notification; Receiving a task completion notification sent by the first application; The system shutdown notification is sent to a target application corresponding to a next target task of the first task according to the task completion notification and the processing order of the multiple target tasks.

6. The method according to claim 4, It is characterized in that The multiple target tasks include a second task whose task type is interactive, and the target application corresponding to the second task is a second application; The sending of the system shutdown notification to the target application corresponding to each target task in sequence according to the processing order of the multiple target tasks includes: sending the system shutdown notification to the second application; receiving a task completion notification sent by the second application, wherein the task completion notification is sent by the second application after the second application has processed the second task according to a triggering operation of the user on the interactive interface when the second application detects the existence of the second task based on the system shutdown notification; The system shutdown notification is sent to a target application corresponding to a next target task of the second task according to the task completion notification and the processing order of the multiple target tasks.

7. The method according to any one of claims 1 to 3, It is characterized in that The multiple target tasks include a third task whose task type is non-interactive, and the target application corresponding to the third task is a third application; The step of controlling the target application corresponding to each target task to process the target task according to the processing order of the multiple target tasks includes: According to the processing order of the multiple target tasks, at each preset time interval, a system shutdown notification is simultaneously sent to the third application corresponding to the third task with the same priority level, and the system shutdown notification is used to instruct the third application to process the corresponding third task within the preset time.

8. A system shutdown control device, It is characterized in that include: At least one unit for performing the method according to any one of claims 1 to 7.

9. An electronic device, It is characterized in that include: A processor, wherein the processor is configured to run a computer program stored in a memory to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • System shutdown control method and apparatus, electronic device, and readable storage medium

    EP4749447A1

  • System shutdown control method and apparatus, electronic device, and readable storage medium

    WO2025118717A1