Task processing method and device, equipment and storage medium
By setting the first trigger and the second trigger in the electronic device, combining the trigger conditions of the target moment and the target state, the problem of uneven task execution rate and number of executions in the prior art is solved, and more efficient task triggering is achieved and execute.
Patent Information
- Application Number
- CN202411398507.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-08
- Publication Date
- 2025-02-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, the alarm clock mechanism requires precise time to trigger, resulting in low trigger execution rate. However, the direct use of the Job mechanism cannot be accurate, and there is a possibility of frequent triggering and multiple executions, making it difficult to achieve the task execution rate and number of executions. equilibrium.
The first trigger and the second trigger are arranged in the electronic device, the first trigger triggers the task at the target moment and the target state, and the second trigger triggers the task in the target state only, thereby not triggering the first trigger In a case, the target task is triggered based on the second trigger.
By combining the first trigger and the second trigger, an equalization between the execution rate and the number of executions of the task is achieved, and the problems of low and frequent triggering of the trigger in the prior art are solved.
Smart Images

Figure CN119415225A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of task processing technology, and relate to but are not limited to a task processing method and apparatus, device, and storage medium. Background Art
[0002] The alarm mechanism and the job mechanism are important mechanisms for controlling and managing task scheduling in computer systems. However, the alarm mechanism must be triggered at a precise time, and the trigger execution rate is low; directly using the job mechanism, the time cannot be precise, and there is the possibility of frequent triggering and multiple executions.
[0003] Therefore, how to achieve a balance between the execution rate and execution times of tasks is an urgent problem to be solved. Summary of the invention
[0004] In view of this, the task processing method, device, equipment, and storage medium provided in the embodiments of the present application can achieve a balance between the execution rate and the number of executions of the task. The task processing method, device, equipment, and storage medium provided in the embodiments of the present application are implemented as follows:
[0005] A task processing method provided in an embodiment of the present application is applied to an electronic device, and the method includes: when the electronic device is provided with a first trigger, obtaining the current time corresponding to the system clock of the electronic device and the current state of the electronic device, the first trigger is used to trigger the execution of the target task when the electronic device is at the target time and in the target state, the target state and the current state are one of the preset states, and the preset state is determined according to whether the electronic device is idle and / or whether the power of the electronic device is greater than a preset power threshold; when the target task is not triggered according to the current time, the current state and the first trigger, triggering the execution of the target task according to the current state and a second trigger, and the second trigger is used to trigger the execution of the target task when the electronic device is in the target state.
[0006] The task processing device provided in the embodiment of the present application is applied to an electronic device, and the device includes: an acquisition module, which is used to acquire the current time corresponding to the system clock of the electronic device and the current state of the electronic device when the electronic device is provided with a first trigger, and the first trigger is used to trigger the execution of the target task when the electronic device is at the target time and in the target state, and the target state and the current state are one of the preset states, and the preset state is determined according to whether the electronic device is idle and / or whether the power of the electronic device is greater than a preset power threshold; a processing module, which is used to trigger the execution of the target task according to the current state and a second trigger when the target task is not triggered according to the current time, the current state and the first trigger, and the second trigger is used to trigger the execution of the target task when the electronic device is in the target state.
[0007] The computer device provided in the embodiment of the present application includes a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the processing method of the task described in the embodiment of the present application is implemented.
[0008] The computer-readable storage medium provided in the embodiment of the present application stores a computer program thereon, and when the computer program is executed by a processor, the processing method of the task provided in the embodiment of the present application is implemented.
[0009] The computer program product provided in the embodiment of the present application includes a computer program, which, when executed by a processor, implements the task processing method provided in the embodiment of the present application.
[0010] In the task processing method, device, equipment, and storage medium provided in the embodiments of the present application, when the electronic device is provided with a first trigger, the current time corresponding to the system clock of the electronic device and the current state of the electronic device are obtained, and the first trigger is used to trigger the execution of the target task when the electronic device is at the target time and in the target state, and the target state and the current state are one of the preset states, and then according to the current time, the current state, and the first trigger, the target task is not triggered, and the execution of the target task is triggered according to the current state and the second trigger. In the case where the first trigger does not trigger the target task, the execution of the target task is triggered based on the second trigger, which can achieve a balance between the execution rate and the number of executions of the task, and solve the technical problems raised in the background technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.
[0012] Figure 1 A schematic diagram of the system architecture of an electronic device provided in one embodiment of the present application;
[0013] Figure 2 A schematic diagram of a process flow for implementing a method for processing a task provided in one embodiment of the present application;
[0014] Figure 3 A schematic diagram of a process flow for implementing a method for processing a task provided in another embodiment of the present application;
[0015] Figure 4 A schematic diagram of a process flow for implementing a method for processing a task provided in yet another embodiment of the present application;
[0016] Figure 5 An overall exemplary flow chart of a method for processing a task provided by one embodiment of the present application;
[0017] Figure 6 A structural schematic diagram of a task processing device provided by one embodiment of the present application;
[0018] Figure 7 A structural schematic diagram of a computer device provided for one embodiment of the present application. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the specific technical solution of the present application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application, but are not used to limit the scope of the present application.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0021] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0022] It should be pointed out that the terms "first\second\third" involved in the embodiments of the present application are used to distinguish similar or different objects, and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0023] The Alarm mechanism and the Job mechanism are important mechanisms for controlling and managing task scheduling in computer systems. Among them, the Alarm mechanism is a mechanism used for scheduled task scheduling in Android, allowing applications to perform certain operations at a specific time. Even if the device is in doze state, the Alarm mechanism can wake up the device to perform tasks; it can also be used to limit the execution time of the program to ensure that the system will not affect the overall performance due to the long-term operation of a task. The Job mechanism involves the management and scheduling of jobs, and is usually used to describe a series of tasks that need to be completed. Each job may contain multiple subtasks. It is also a task scheduling framework provided by Android 5.0+, allowing developers to perform tasks when conditions are met, such as when the device is charging, the network is available, etc. It has stronger power conservation and optimizes the background behavior of applications.
[0024] However, since the Alarm mechanism must be triggered at a precise time, if the trigger condition is missed and the Alarm trigger task is not triggered at the precise time, it can only wait for the next Alarm cycle to be triggered, and the trigger execution rate is low; directly using the Job mechanism cannot accurately determine the time, and the response speed is slow for precise timing tasks that need to be executed immediately; in addition, there is the possibility of frequent triggering and multiple executions.
[0025] Therefore, how to achieve a balance between the execution rate and execution times of tasks is an urgent problem to be solved.
[0026] In view of this, an embodiment of the present application provides a method for processing a task, which is applied to an electronic device, and the method specifically includes: when the electronic device is provided with a first trigger, obtaining the current time corresponding to the system clock of the electronic device and the current state of the electronic device, the first trigger is used to trigger the execution of the target task when the electronic device is at the target time and in the target state, the target state and the current state are one of the preset states, and then according to the current time, the current state and the first trigger, the target task is not triggered, and the execution of the target task is triggered according to the current state and the second trigger. In the task processing method of the present application, when the first trigger does not trigger the target task, the execution of the target task is triggered based on the second trigger, which can achieve a balance between the execution rate and the number of executions of the task.
[0027] It should be understood that the electronic devices involved in the embodiments of the present application may be mobile phones, tablet computers, laptop computers, PDAs, mobile internet devices (MIDs), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, smart screens, artificial intelligence (AI) speakers, headphones, terminals in industrial control, terminals in self-driving, terminals in remote medical surgery, terminals in smart grids, terminals in transportation safety, terminals in smart cities, terminals in smart homes, personal digital assistants (PDAs), etc., and the embodiments of the present application are not limited to this.
[0028] For example, Figure 1 A schematic diagram of the system architecture of an electronic device provided in one embodiment of the present application. Figure 1 As shown, the electronic device includes components such as a processor 110, a memory 120, a transceiver 130, a display unit 140, an input unit 150, and a power module 160.
[0029] The processor 110 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 120, and calling data stored in the memory 120, the processor 110 performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 110 may include one or more processing units; optionally, the processor 110 may integrate an application processor, which mainly processes operating devices, user interfaces, and application programs, etc. Of course, other processors may also be included, which are not listed here one by one.
[0030] The memory 120 can be used to store software programs and modules. The processor 110 executes various functional applications and data processing of the electronic device by running the software programs and modules stored in the memory 120. The memory 120 mainly includes a program storage area and a data storage area, wherein the program storage area can store operating devices, at least one application required for a function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the electronic device (such as audio data, a phone book, etc.), etc. In addition, the memory 120 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, or other volatile solid-state storage devices.
[0031] The transceiver 130 can provide wireless communication solutions for electronic devices, 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. The transceiver 130 can be one or more devices integrating at least one communication processing module, for example, an antenna and a baseband processor are integrated into the transceiver 130, or an antenna and a modem processor are integrated into the transceiver 130, etc., which are not limited here.
[0032] The display unit 140 may be used to display information input by a user or information provided to a user and various menus of the electronic device. The display unit 140 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc., which is not limited here.
[0033] The input unit 150 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the input unit 150 can collect the user's operations on or near it, and drive the corresponding connection device according to a pre-set program. In addition, the input unit 150 may include a touch panel, which can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel, the input unit 150 may also include other input devices. Specifically, other input devices may include, but are not limited to, one or more of function keys (such as volume control keys, switch keys, etc.), trackballs, joysticks, etc.
[0034] The electronic device also includes a power module 160 for supplying power to various components. Optionally, the power module 160 can be logically connected to the processor 110 through a power management device, so that the power management device can manage charging, discharging, power consumption and other functions.
[0035] Although not shown, the electronic device may further include a camera. Optionally, the camera may be located at the front or rear of the electronic device, which is not limited in the present embodiment.
[0036] It is to be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown in the figure, or combine certain components, or split certain 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.
[0037] In order to make the purpose and technical solution of this application clearer and more intuitive, the following will be combined with the accompanying drawings and embodiments to describe in detail the task processing method and device, equipment, and storage medium provided in the embodiments of this application. It should be understood that the specific embodiments described herein are only used to explain this application and are not used to limit this application.
[0038] Please refer to Figure 2 , is a schematic diagram of the implementation flow of a task processing method provided by an embodiment of the present application. The method can be applied to Figure 1 The electronic equipment shown, such as Figure 2 As shown, the method may include the following steps 201 and 202:
[0039] Step 201, when the electronic device is provided with a first trigger, obtain the current time corresponding to the system clock of the electronic device and the current state of the electronic device, the first trigger is used to trigger the execution of the target task when the electronic device is at the target time and in the target state.
[0040] Among them, the target state and the current state are one of the preset states, and the preset state is determined according to whether the electronic device is idle and / or whether the power of the electronic device is greater than a preset power threshold.
[0041] In some embodiments, the first trigger is registered when the electronic device is turned on or the screen of the electronic device is turned off. Exemplarily, the first trigger is registered when the electronic device is turned on. If the registration fails when the electronic device is turned on, the first trigger can be registered when the screen of the electronic device is turned off. Both times are acceptable, and this application does not limit this.
[0042] In some embodiments, a system clock module may be used to obtain the current time of the electronic device, which is usually implemented using a system application programming interface (Application Programming Interface, API).
[0043] In some embodiments, the preset state is determined based on whether the electronic device is idle and / or whether the power of the electronic device is greater than a preset power threshold. For example, when the electronic device is in a charging state and the screen is off, the electronic device can be considered to be in an idle state; when the usage rate of the central processing unit (CPU) of the electronic device is lower than a certain value, the electronic device is considered to be in an idle state; when the power of the electronic device is greater than a preset power threshold, the electronic device is considered to be in a high power state, etc.
[0044] In some embodiments, the target task may be starting a service, sending a signal, a system optimization task, a model training task, etc.
[0045] Step 202, when the target task is not triggered according to the current time, the current state and the first trigger, trigger the execution of the target task according to the current state and the second trigger, and the second trigger is used to trigger the execution of the target task when the electronic device is in the target state.
[0046] It should be noted that the first trigger and the second trigger can be preset in advance and stored in the electronic device, and called when the conditions are met; or the first trigger can be preset in the electronic device in advance, and the second trigger can be registered only when the first trigger does not trigger the target task. This application does not specifically limit this.
[0047] In some embodiments, when the first trigger does not trigger the target task, the electronic device determines the current state of the electronic device and whether the current state is the target state based on whether the electronic device is idle and / or whether the power of the electronic device is greater than a preset power threshold, and when the electronic device is in the target state, calls the second trigger to trigger the execution of the target task. In other words, calling the second trigger to trigger the execution of the target task is performed when the first trigger does not trigger the target task. The first trigger triggers the execution of the target task to meet the target time and target state. When the electronic device misses the target time, or meets the target time but does not meet the target state, the target task is executed according to the current state and the second trigger to trigger the execution of the target task, ensuring that the electronic device can effectively trigger the target task.
[0048] In this embodiment, when the electronic device is provided with a first trigger, the current time corresponding to the system clock of the electronic device and the current state of the electronic device are obtained, and the first trigger is used to trigger the execution of the target task when the electronic device is at the target time and in the target state, and the target state and the current state are one of the preset states, and then according to the current time, the current state and the first trigger, the target task is triggered according to the current state and the second trigger. Since the first trigger needs to meet the target time, if the target time is missed, it has to wait for the next cycle, so the trigger rate is low; and the second trigger only needs to meet the target state, so the first trigger and the second trigger are combined to trigger the execution of the target task, that is, when the first trigger does not trigger the target task, the target task is triggered based on the second trigger, which can achieve a balance between the execution rate and the number of executions of the task.
[0049] Based on the above embodiments, Figure 3 A schematic diagram of a process flow for implementing a task processing method provided in another embodiment of the present application is shown in FIG. Figure 3 As shown, the method may include the following steps 301 to 304:
[0050] Step 301, when the electronic device is provided with a first trigger, obtain the current time corresponding to the system clock of the electronic device and the current state of the electronic device, the first trigger is used to trigger the execution of the target task when the electronic device is at the target time and in the target state.
[0051] Among them, the target state and the current state are one of the preset states, and the preset state is determined according to whether the electronic device is idle and / or whether the power of the electronic device is greater than a preset power threshold.
[0052] In some embodiments, the first trigger is registered when the electronic device is turned on or the screen of the electronic device is turned off.
[0053] In some embodiments, the preset state is determined based on whether the electronic device is idle and / or whether the power of the electronic device is greater than a preset power threshold. For example, when the electronic device is in a charging state and the screen is off, the electronic device can be considered to be in an idle state; when the CPU usage rate of the electronic device is lower than a certain value, the electronic device is considered to be in an idle state; when the power of the electronic device is greater than a preset power threshold, the electronic device is considered to be in a high power state, etc.
[0054] In some embodiments, the target task may be starting a service, sending a signal, a system optimization task, a model training task, etc.
[0055] Optionally, the first trigger includes an Alarm trigger, and the second trigger includes a Job trigger.
[0056] Step 302, when the first trigger does not trigger the target task according to the current time, the current state, and the electronic device is not set with the second trigger, register the second trigger.
[0057] In some embodiments, the electronic device may register a second trigger when the current moment is the target moment and the current state is not the target state.
[0058] That is, the electronic device can first determine whether the current moment of the electronic device is the target moment, and if the current moment of the electronic device is the target moment, determine whether the current state of the electronic device is the target state. If it is not the target state, the first trigger does not trigger the target task. At this time, if the electronic device does not set the second trigger, register the second trigger. The electronic device can also first determine whether the current state of the electronic device is the target state. If the current state of the electronic device is not the target state, determine whether the current moment of the electronic device is the target moment. If it is the target moment and the electronic device does not set the second trigger, register the second trigger, or register the second trigger after a few minutes.
[0059] Optionally, if the electronic device has missed the target time and the first trigger has not triggered the target task, then if the electronic device has not set the second trigger, the second trigger is registered.
[0060] Step 303, determining whether the target cycle is finished, where the target cycle is used to indicate the execution cycle of the target task.
[0061] In some embodiments, the electronic device is preset with an execution cycle for executing the target task, that is, a target cycle, which may start from 0:00 every day and last for 24 hours. If a target cycle ends, the next target cycle will be restarted from step 301. The setting of the target cycle can also adjust the length and inspection frequency according to actual needs to ensure the flexibility and responsiveness of the system.
[0062] Step 304, when the target cycle has not ended, trigger the execution of the target task according to the current state and a second trigger, and the second trigger is used to trigger the execution of the target task when the electronic device is in the target state.
[0063] In some embodiments, when the electronic device determines that the target cycle has not ended, it determines the current state of the electronic device and whether the current state is the target state based on whether the electronic device is idle and / or whether the power of the electronic device is greater than a preset power threshold. When the electronic device is in the target state, the second trigger is called to trigger the execution of the target task.
[0064] In this embodiment, when the electronic device is provided with a first trigger, the current time corresponding to the system clock of the electronic device and the current state of the electronic device are obtained. When the target task is not triggered according to the current time, the current state, and the first trigger, and the electronic device is not provided with a second trigger, a second trigger is registered. Further, it is determined whether the target cycle is ended. The target cycle is used to indicate the execution cycle of the target task. When the target cycle is not ended, the execution of the target task is triggered according to the current state and the second trigger. Through the trigger mechanism, automatic management of device status and task execution can be achieved, and the system response speed can be improved; when the first trigger fails to trigger the execution of the target task, the target task can be executed in time based on the second trigger, which can optimize resource utilization, ensure that the task is completed within the appropriate time, and reduce waiting time; by judging the target cycle, the execution timing of the task can be accurately controlled to avoid unnecessary repeated execution or omissions; through clear trigger conditions and status judgments, system failures caused by erroneous triggering or execution can be reduced, and the reliability of the overall system can be improved; in addition, since the first trigger needs to meet the target time, if the target time is missed, it has to wait for the next cycle, so the trigger rate is low; and the second trigger only needs to meet the target state, so combining the first trigger and the second trigger to trigger the execution of the target task can achieve a balance between the execution rate and the number of executions of the task, thereby enhancing the user experience.
[0065] Based on the above embodiments, Figure 4 A schematic diagram of a process flow for implementing a task processing method provided in another embodiment of the present application is shown in FIG. Figure 4In the embodiment shown, the target state of the electronic device is that the electronic device enters a state of charging and the screen is off, for example. Figure 4 As shown, the method may include the following steps 401 to 406:
[0066] Step 401, when the electronic device is provided with a first trigger, obtain the current time corresponding to the system clock of the electronic device and the current state of the electronic device, the first trigger is used to trigger the execution of the target task when the electronic device is at the target time and in the target state.
[0067] It should be noted that the target state and the current state are one of the preset states. The preset state is determined based on whether the electronic device is idle. Whether the electronic device is idle is determined based on whether the electronic device is charging and the screen is off. The target state of the electronic device is when the electronic device is charging and the screen is off.
[0068] In some embodiments, the first trigger is registered when the electronic device is turned on or the screen of the electronic device is turned off. Exemplarily, the first trigger is registered when the electronic device is turned on. If the registration fails when the electronic device is turned on, the first trigger can be registered when the screen of the electronic device is turned off. Both times are acceptable, and this application does not limit this.
[0069] In some embodiments, the target task may be starting a service, sending a signal, a system optimization task, a model training task, etc.
[0070] Step 402, determining whether the current time is the target time.
[0071] In some embodiments, the electronic device compares the acquired current time with the target time to see whether the two times are consistent. If they are consistent, the current time is determined to be the target time.
[0072] Optionally, the level of time comparison can be determined according to user needs, such as accuracy to seconds or milliseconds, etc. At the same time, ensure that the current time and the target time are in the same time zone to avoid comparison errors caused by time zone differences and improve the accuracy of judgment.
[0073] Step 403, when the current moment is the target moment, detect whether the electronic device has entered charging and the screen is turned off.
[0074] In some embodiments, when the current moment is the target moment, the electronic device detects whether the electronic device enters a charging state, for example, detects whether the electronic device is connected to a power source. If the electronic device enters a charging state, it further detects whether the screen of the electronic device is off.
[0075] Optionally, if the screen of the electronic device is turned off, the duration of the screen being turned off of the electronic device can also be detected.
[0076] Step 404: When the electronic device is not charging, or when the electronic device is charging and the screen is not off, it is determined that the first trigger has not triggered the target task.
[0077] In some embodiments, when the electronic device is not charging, or when the electronic device is charging and the screen is not off, it means that the electronic device is in a non-idle state. Even if the target time is met, the first trigger cannot be called, so it is determined that the first trigger did not trigger the target task. Through the above condition detection, the state of the first trigger can be effectively judged, thereby determining the subsequent operation, ensuring the responsiveness of the electronic device under specific conditions and ensuring the smoothness of the user experience.
[0078] Step 405, based on the current time, the current state and the first trigger not triggering the target task, reacquire the current state of the electronic device to obtain an updated current state.
[0079] In some embodiments, the second trigger is registered when the current moment is the target moment and the current state is not the target state. That is to say, the action of registering the second trigger is performed at the target moment, and the registration completion moment of the second trigger is after the target moment. If the second trigger registration process lasts for a long time due to some special circumstances, then after the second trigger registration is completed, the current state of the electronic device may have changed.
[0080] Therefore, the electronic device can also obtain the time interval between the registration completion moment and the target moment when registering the second trigger. When the time interval is greater than the preset time interval threshold, the current state of the electronic device is re-obtained to obtain the updated current state, ensuring that the system always maintains the latest perception of the state of the electronic device, thereby being able to make timely and effective responses, thereby improving the intelligence level of the device and user experience.
[0081] Step 406: trigger execution of the target task according to the updated current state and a second trigger, wherein the second trigger is used to trigger execution of the target task when the electronic device is in the target state.
[0082] In some embodiments, when the first trigger does not trigger the target task, the electronic device determines the updated current state of the electronic device and whether the updated current state is the target state based on whether the electronic device is idle and / or whether the power of the electronic device is greater than a preset power threshold, and when the electronic device is in the target state, calls the second trigger to trigger the execution of the target task. In other words, calling the second trigger to trigger the execution of the target task is performed when the first trigger does not trigger the target task. The first trigger triggers the execution of the target task to meet the target time and the target state. When the electronic device misses the target time, or meets the target time but does not meet the target state, the target task is executed according to the updated current state and the second trigger to ensure that the electronic device can effectively trigger the target task.
[0083] In this embodiment, when the electronic device is provided with a first trigger, the current time corresponding to the system clock of the electronic device and the current state of the electronic device are obtained, and then it is determined whether the current time is the target time. When the current time is the target time, it is detected whether the electronic device has entered charging and the screen is turned off. When the electronic device has not entered charging, or the electronic device has entered charging and the screen is not turned off, it is determined that the first trigger has not triggered the target task; further, according to the current time, the current state, and the first trigger has not triggered the target task, the current state of the electronic device is re-acquired to obtain the updated current state, and the target task is executed according to the updated current state and the second trigger. By judging whether the electronic device has entered charging and whether the screen is turned off, energy consumption can be reduced when it is not needed and the battery life can be extended; the combined use of the first trigger and the second trigger enables the electronic device to dynamically adjust the task execution according to the real-time state, ensure that the operation is performed at the most appropriate time, and improve the system response efficiency; by automatically detecting and judging the device status, unnecessary intervention can be avoided, allowing users to enjoy a smoother operating experience. In addition, since the first trigger needs to meet the target time, if the target time is missed, it has to wait for the next cycle, so the trigger rate is low; while the second trigger only needs to meet the target state, so combining the first trigger and the second trigger to trigger the execution of the target task can achieve a balance between the task execution rate and the number of executions, thereby enhancing the user experience.
[0084] Based on the above embodiment, taking the adaptive trigger training of the terminal model as an example, the first trigger is the Alarm trigger and the second trigger is the Job trigger, assuming that the user sets the process of triggering the training task once a day on the mobile phone, for example, setting it to trigger the execution of the training task at 1 a.m. every day when the device is charging and the screen is off, please refer to Figure 5 , is an overall exemplary flow chart of a method for processing a task provided by an embodiment of the present application, such as Figure 5As shown, after the task starts, the method may include the following steps 501 to 509:
[0085] Step 501, register an Alarm trigger.
[0086] In some embodiments, the Alarm trigger is registered when the electronic device is turned on or the screen of the electronic device is turned off. Exemplarily, the Alarm trigger is registered when the electronic device is turned on. If the registration fails when the electronic device is turned on, the Alarm trigger can be registered when the screen of the electronic device is turned off. Both times are acceptable, and this application does not limit this.
[0087] Step 502, determine whether the current time of the electronic device is 1:00 a.m. If the current time of the electronic device is 1:00 a.m., execute step 503; if the current time of the electronic device is not 1:00 a.m., execute step 506.
[0088] Step 503, determine whether the electronic device has entered a charging state. If the electronic device has entered a charging state, execute step 504; if the electronic device has not entered a charging state, execute step 506.
[0089] Step 504, determine whether the screen of the electronic device is off. If the screen of the electronic device is off, execute step 505; if the screen of the electronic device is not off, execute step 506.
[0090] Optionally, the electronic device may be configured to execute step 505 after the screen is turned off for 5 minutes. If the screen is awakened within less than 5 minutes, step 506 may be executed.
[0091] Step 505, executing the training task.
[0092] It should be noted that since the user sets the training task to be triggered once a day, the training task for that day ends after a training task is successfully executed.
[0093] Step 506, register the Job trigger.
[0094] Step 507, determine whether the electronic device has entered a charging state. If the electronic device has entered a charging state, execute step 508; if the electronic device has not entered a charging state, execute step 509.
[0095] Step 508, determine whether the electronic device has been off for 5 minutes. If the electronic device has been off for 5 minutes, execute step 505; if the electronic device has not been off, or has been awakened after being off for less than 5 minutes, execute step 509.
[0096] Optionally, the electronic device may be configured to execute step 505 if the screen is turned off, and execute step 509 if the screen is not turned off.
[0097] Step 509, determine whether the day is over. If the day is over, the cycle of executing the training task is over; if the day is not over, step 506 is re-executed until the day is over or the training task is over.
[0098] In this embodiment, the electronic device first registers an Alarm trigger, and then triggers the training task at 1 a.m. when the device is charging and the screen is off. If any of the above conditions is not met, a Job trigger is registered; then the training task is triggered when the electronic device is charging and the screen is off. If any of the above conditions is not met, a cyclic Job trigger scheduling is performed until the training task is triggered when all conditions are met within one day.
[0099] In the current related technologies, the probability of triggering by directly using the Alarm mechanism is very low because it depends on the precise time of the Alarm; directly using the Job mechanism and repeating the Job will have a much higher probability of triggering, but to ensure that it is only triggered once a day, it can only be triggered once every 24 hours. At this time, it is difficult for technicians to know when it will be triggered, and the triggering timing may be different every day and unpredictable. Compared with the use of these two trigger mechanisms separately in the current related technologies, the solution in the embodiment of the present application uses the Alarm trigger mechanism to accurately determine the time to meet the debugging user scenario; if the precise time is not triggered, then the Job trigger mechanism will be used later, and it will be triggered after the screen is turned off during charging, which can make the execution of the task predictable and easy to trigger, and achieve a balance between the execution rate and the number of executions of the task. At the same time, background tasks are triggered when the device is idle to avoid affecting the user experience.
[0100] For another example, in some scenarios where the background automatically performs system optimization tasks, the task processing method in the embodiment of the present application can also be used.
[0101] It should be understood that, although the steps in the above-mentioned flowcharts are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the above-mentioned flowcharts may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0102] Based on the foregoing embodiments, an embodiment of the present application provides a task processing device, which includes the modules included and the units included in the modules, and can be implemented by a processor; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit, a microprocessor, a digital signal processor or a field programmable gate array, etc.
[0103] Figure 6 A structural diagram of a task processing device provided in one embodiment of the present application is shown as follows: Figure 6 As shown, the task processing device 600 includes an acquisition module 601 and a processing module 602, wherein:
[0104] An acquisition module 601 is used to acquire the current time corresponding to the system clock of the electronic device and the current state of the electronic device when the electronic device is provided with a first trigger, the first trigger being used to trigger the execution of a target task when the electronic device is at a target time and in a target state, the target state and the current state being one of preset states, and the preset state being determined based on whether the electronic device is idle and / or whether the power of the electronic device is greater than a preset power threshold; a processing module 602 is used to trigger the execution of the target task according to the current state and a second trigger when the target task is not triggered according to the current time, the current state and the first trigger, the second trigger being used to trigger the execution of the target task when the electronic device is in the target state.
[0105] In some embodiments, the apparatus further includes: a registration module. The registration module is configured to register the second trigger if the electronic device is not set with the second trigger.
[0106] In some embodiments, the registration module is specifically used to: register the second trigger when the current moment is the target moment and the current state is not the target state.
[0107] In some embodiments, the processing module 602 is specifically used to: determine whether the target cycle has ended, the target cycle is used to indicate the execution cycle of the target task; if the target cycle has not ended, trigger the execution of the target task according to the current state and the second trigger.
[0108] In some embodiments, the preset state is determined based on whether the electronic device is idle, and whether the electronic device is idle is determined based on whether the electronic device enters charging and the screen is turned off, and the target state of the electronic device is the state where the electronic device enters charging and the screen is turned off, and the device includes: a judgment module, a detection module, and a determination module. The judgment module is used to judge whether the current moment is the target moment; the detection module is used to detect whether the electronic device enters charging and the screen is turned off when the current moment is the target moment; the determination module is used to determine that the first trigger does not trigger the target task when the electronic device does not enter charging, or when the electronic device enters charging and the screen is not turned off.
[0109] In some embodiments, the acquisition module 601 is also used to reacquire the current state of the electronic device to obtain an updated current state; the processing module 602 is specifically used to: trigger the execution of the target task according to the updated current state and the second trigger.
[0110] In some embodiments, the second trigger is registered when the current moment is the target moment and the current state is not the target state, and the acquisition module 601 is also used to obtain the time interval between the registration completion moment and the target moment when registering the second trigger; the acquisition module 601 is specifically used to: when the time interval is greater than a preset time interval threshold, re-acquire the current state of the electronic device to obtain an updated current state.
[0111] In some embodiments, the registration module is further used to register the first trigger when the electronic device is turned on or the screen of the electronic device is turned off.
[0112] In some embodiments, the first trigger includes an alarm trigger, and the second trigger includes a job trigger.
[0113] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0114] It should be noted that in the embodiments of this application Figure 6The division of modules by the processing device of the task shown is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional unit in each embodiment of the present application may be integrated into a processing unit, or 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 a software functional unit. It may also be implemented in the form of a combination of software and hardware.
[0115] It should be noted that in the embodiment of the present application, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable an electronic device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.
[0116] The embodiment of the present application provides a computer device, which may be a server, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the above method is implemented.
[0117] An embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the method provided in the above embodiment are implemented.
[0118] An embodiment of the present application provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute the steps of the method provided in the above method embodiment.
[0119] Those skilled in the art will understand that Figure 7The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0120] In one embodiment, the task processing device provided by the present application can be implemented in the form of a computer program, which can be used in Figure 7 The computer device shown in the figure is run. The memory of the computer device can store various program modules constituting the above-mentioned device. The computer program composed of various program modules enables the processor to execute the steps in the method of each embodiment of the present application described in this specification.
[0121] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium, storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0122] It should be understood that "one embodiment" or "an embodiment" or "some embodiments" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in one embodiment" or "in some embodiments" appearing throughout the specification may not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments. The above description of each embodiment tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. For the sake of brevity, this article will not repeat them.
[0123] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, object A and / or object B can represent three situations: object A exists alone, object A and object B exist at the same time, and object B exists alone.
[0124] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0125] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or modules can be electrical, mechanical or other forms.
[0126] The modules described above as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules; they may be located in one place or distributed on multiple network units; some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment.
[0127] In addition, all functional modules in the embodiments of the present application may be integrated into one processing unit, or each module may be a separate unit, or two or more modules may be integrated into one unit; the above-mentioned integrated modules may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0128] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.
[0129] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling an electronic device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0130] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0131] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0132] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0133] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which 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 task processing method, characterized in that: Applied to electronic equipment, the method comprises: In a case where the electronic device is provided with a first trigger, obtaining a current time corresponding to a system clock of the electronic device and a current state of the electronic device, wherein the first trigger is used to trigger execution of a target task when the electronic device is at a target time and in a target state, wherein the target state and the current state are one of preset states, and the preset state is determined according to whether the electronic device is idle and / or whether the power of the electronic device is greater than a preset power threshold; When the target task is not triggered according to the current time, the current state and the first trigger, the target task is executed according to the current state and the second trigger, and the second trigger is used to trigger the execution of the target task when the electronic device is in the target state.
2. The method according to claim 1, characterized in that Before triggering the execution of the target task according to the current state and the second trigger, the method further includes: If the second trigger is not set in the electronic device, the second trigger is registered.
3. The method according to claim 2, characterized in that The registering the second trigger comprises: When the current time is the target time and the current state is not the target state, the second trigger is registered.
4. The method according to claim 1, characterized in that The triggering execution of the target task according to the current state and the second trigger includes: Determining whether a target cycle has ended, the target cycle being used to indicate an execution cycle for executing the target task; When the target cycle has not ended, the target task is executed according to the current state and a second trigger.
5. The method according to claim 1, characterized in that The preset state is determined according to whether the electronic device is idle, and whether the electronic device is idle is determined according to whether the electronic device enters charging and the screen is off, and the target state of the electronic device is a state in which the electronic device enters charging and the screen is off. Before the execution of the target task is triggered according to the current state and the second trigger, the method further includes: Determining whether the current moment is the target moment; When the current moment is the target moment, detecting whether the electronic device has entered charging state and the screen is turned off; When the electronic device is not in charging mode, or when the electronic device is in charging mode and the screen is not turned off, it is determined that the first trigger does not trigger the target task.
6. The method according to claim 1, characterized in that Before executing the target task according to the current state and the second trigger, the method further includes: Re-acquiring the current state of the electronic device to obtain an updated current state; The triggering execution of the target task according to the current state and the second trigger includes: The target task is executed according to the updated current state and the second trigger.
7. The method according to claim 6, characterized in that The second trigger is registered when the current moment is the target moment and the current state is not the target state. Before reacquiring the current state of the electronic device to obtain an updated current state, the method further includes: Acquire the time interval between the registration completion time and the target time when registering the second trigger; The reacquiring the current state of the electronic device to obtain an updated current state includes: When the time interval is greater than a preset time interval threshold, the current state of the electronic device is reacquired to obtain an updated current state.
8. The method according to claim 1, characterized in that Before acquiring the current time corresponding to the system clock of the electronic device and the current state of the electronic device, the method further includes: When the electronic device is turned on or the screen of the electronic device is turned off, the first trigger is registered.
9. The method according to claim 1, characterized in that: The first trigger includes an alarm trigger, and the second trigger includes a job trigger.
10. A task processing device, characterized in that: Applied to electronic equipment, the device comprises: an acquisition module, configured to acquire, when the electronic device is provided with a first trigger, a current time corresponding to a system clock of the electronic device and a current state of the electronic device, wherein the first trigger is configured to trigger execution of a target task when the electronic device is at a target time and in a target state, wherein the target state and the current state are one of preset states, and the preset state is determined according to whether the electronic device is idle and / or whether the power of the electronic device is greater than a preset power threshold; A processing module is used to trigger the execution of the target task according to the current state and a second trigger when the target task is not triggered according to the current moment, the current state and the first trigger. The second trigger is used to trigger the execution of the target task when the electronic device is in the target state.
11. A computer device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 9 are implemented.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.