Processing methods for electronic devices, electronic devices, storage media and software products
By setting preset cycles for multiple detection stages in electronic devices, anomalies are detected and recovered in a graded manner, solving the problem that software watchdogs cannot effectively recover, and improving system stability and data protection.
Patent Information
- Application Number
- CN202510637847.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2026-11-17
AI Technical Summary
Existing software watchdogs cannot effectively recover in abnormal scenarios, leading to reduced system performance and impacting user experience.
By setting preset cycles for multiple detection stages, and based on the timing and correlation of the detection stages, anomalies are detected and recovered in a tiered manner, and pending tasks are terminated to reduce restarts and protect data.
It improves the operational stability and data protection capabilities of electronic devices, and reduces user waiting time and data loss.
Smart Images

Figure CN123114852A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of smart terminals, and more particularly to a processing method for an electronic device, an electronic device, a storage medium, and a program product. Background Technology
[0002] A watchdog timer can be either software or hardware. Regardless of whether it's software or hardware, current implementations typically have one input and one output. The input is called "kicking the dog" or "service the dog," and the output is generally used to reset the detected business process when it encounters an anomaly, thus restoring the detected process to normal operation.
[0003] Taking software watchdogs as an example, although current software watchdogs can recover the business processes they detect, they cannot effectively recover in some abnormal scenarios, leading to reduced system performance and affecting user experience. Summary of the Invention
[0004] To overcome the problems in related technologies, this disclosure provides a processing method for an electronic device, an electronic device, a storage medium, and a program product. By setting different detection stages and recovering from anomalies in each detection stage, not only is the stability of the electronic device's operation improved, but also the effect of protecting some data is achieved.
[0005] According to a first aspect of the present disclosure, a processing method for an electronic device is provided, comprising:
[0006] In response to entering any detection phase of a preset period, based on the timing of the detection phase within the preset period, a task to be processed in the detection phase is determined from the target tasks; wherein the target task is created within the preset period, and the preset period includes at least two detection phases; each detection phase is sequentially continuous; the correlation between terminating the task to be processed and the restart of the electronic device is positively correlated with the timing of the detection phases;
[0007] If an anomaly is determined to exist in the electronic device based on the task to be processed, the anomaly is recovered based on the recovery strategy corresponding to the detection phase.
[0008] The method described in this embodiment not only improves the stability of electronic equipment operation, but also protects some data.
[0009] In some embodiments, determining the tasks to be processed in the detection phase from the target tasks based on the timing of the detection phase within the preset period includes:
[0010] For each of the target tasks, determine the process associated with the target task;
[0011] The processes associated with each of the target tasks are compared with the reference processes in the process set corresponding to the detection stage to obtain a first comparison result; wherein, each detection stage corresponds to a process set, and the degree of association between interrupting the reference processes in different process sets and the restart of the electronic device is different;
[0012] If the first comparison result indicates that there is a target process that matches any reference process in the process set, the target task corresponding to the target process is determined as the task to be processed.
[0013] The method described in this disclosure enables graded detection and improves the efficiency of restoring electronic devices.
[0014] In some embodiments, methods for determining that the electronic device is malfunctioning based on the task to be processed include:
[0015] The communication duration of at least two target processes is determined from the call chain information during the execution of the task to be processed; wherein, the call chain information represents the link information of the communication between the at least two target processes based on the inter-process communication mechanism;
[0016] If the duration of any of the communication sessions exceeds the duration threshold corresponding to the detection phase, it is determined that the electronic device has the anomaly; wherein each detection phase corresponds to a duration threshold.
[0017] The method of this disclosure improves the accuracy of executing recovery strategies.
[0018] In some embodiments, the method further includes:
[0019] Identify the reference process that caused the electronic device to malfunction, and determine the correlation between an interruption operation on the reference process and a restart of the electronic device;
[0020] Based on the correlation, the reference process is stored in the corresponding process set.
[0021] The electronic device can accurately identify and process different types of target processes through the methods of this disclosure, effectively improving recovery efficiency.
[0022] In some embodiments, the recovery of the anomaly based on the recovery strategy corresponding to the detection phase includes:
[0023] Based on the invocation status of at least two target processes associated with the task to be processed, determine the cause of the abnormality that led to the abnormality in the electronic device;
[0024] Based on the aforementioned cause of the anomaly, a process to be processed is determined from the at least two target processes;
[0025] Based on the recovery strategy corresponding to the detection phase, the process to be processed is processed.
[0026] The method described in this disclosure improves the accuracy of recovering electronic devices and reduces data loss.
[0027] In some embodiments, processing the process to be processed based on the recovery strategy corresponding to the detection phase includes:
[0028] If the abnormality exists in the first detection phase of the preset period, the pending process determined in the first detection phase is interrupted.
[0029] The first detection stage is the first detection stage of the preset cycle.
[0030] The method described in this embodiment can both effectively recover from a frozen system and protect user data.
[0031] In some embodiments, processing the process to be processed based on the recovery strategy corresponding to the detection phase includes:
[0032] If the anomaly exists in the first time unit of the second detection phase of the preset period, the process information of the process to be processed determined by the first time unit is stored; wherein, the second detection phase is the detection phase following the first detection phase;
[0033] If the abnormality exists in the second time unit of the second detection phase, the process to be processed determined by the second time unit is processed based on the second comparison result between the process information of the process to be processed determined by the second time unit and the process information stored in the first time unit.
[0034] The second time unit is sequentially continuous with the first time unit.
[0035] The method described in this disclosure reduces the randomness of anomaly detection and improves the accuracy of restarting electronic devices.
[0036] In some embodiments, processing the process to be processed determined by the second time unit based on the second comparison result between the process information of the process to be processed determined by the second time unit and the process information stored in the first time unit includes:
[0037] If the second comparison result indicates that the process information of the second time unit matches the process information of the first time unit, the electronic device is restarted.
[0038] The method described in this disclosure can accurately and quickly restore electronic devices.
[0039] In some embodiments, processing the process to be processed determined by the second time unit based on the second comparison result between the process information of the process to be processed determined by the second time unit and the process information stored in the first time unit includes:
[0040] If the second comparison result indicates that the process information of the second time unit does not match the process information of the first time unit, the process information stored in the first time unit is cleared.
[0041] If the abnormal duration reaches the first threshold, the pending process determined by the second time unit is interrupted;
[0042] Wherein, the first threshold is greater than the duration threshold corresponding to the second detection stage.
[0043] The method described in this disclosure can reduce the occurrence of invalid restarts of electronic devices and reduce the loss of user data.
[0044] In some embodiments, the step of determining the tasks to be processed in the detection phase from the target tasks based on the timing of the detection phases within the preset period in response to entering any detection phase of a preset period includes:
[0045] In response to entering the first detection phase of the preset period, if the duration of entering the first detection phase reaches a second threshold, the step of determining the task to be processed from the target task based on the first time interval is repeated until the second detection phase is entered from the first detection phase.
[0046] In response to entering the second detection phase, the step of determining the task to be processed from the target task based on the second time interval is repeated until the next preset cycle is entered;
[0047] The second time interval is greater than the first time interval.
[0048] The method described in this disclosure reduces the occurrence of invalid restarts of electronic devices and reduces the loss of user data.
[0049] According to a second aspect of the present disclosure, an electronic device is provided, comprising:
[0050] The determination module is configured to, in response to entering any detection phase of a preset period, determine the pending task of the detection phase from the target tasks based on the timing of the detection phase within the preset period; wherein the target task is created within the preset period, and the preset period includes at least two detection phases; each detection phase is sequentially consecutive; the correlation between terminating the pending task and the restart of the electronic device is positively correlated with the timing of the detection phases;
[0051] The recovery module is configured to recover from the anomaly based on the recovery strategy corresponding to the detection phase when it is determined that the electronic device has an anomaly based on the task to be processed.
[0052] In some embodiments, the determining module is specifically configured as follows:
[0053] For each of the target tasks, determine the process associated with the target task;
[0054] The processes associated with each of the target tasks are compared with the reference processes in the process set corresponding to the detection stage to obtain a first comparison result; wherein, each detection stage corresponds to a process set, and the degree of association between interrupting the reference processes in different process sets and the restart of the electronic device is different;
[0055] If the first comparison result indicates that there is a target process that matches any reference process in the process set, the target task corresponding to the target process is determined as the task to be processed.
[0056] In some embodiments, the device further includes:
[0057] The anomaly detection module is configured to determine the communication duration of at least two target processes from the call chain information when the task to be processed is executed; wherein, the call chain information represents the link information of the communication between the at least two target processes based on the inter-process communication mechanism;
[0058] If the duration of any of the communication sessions exceeds the duration threshold corresponding to the detection phase, it is determined that the electronic device has the anomaly; wherein each detection phase corresponds to a duration threshold.
[0059] In some embodiments, the device further includes:
[0060] The generation module is configured to determine a reference process that causes the electronic device to malfunction, and to determine the correlation between an interruption operation on the reference process and a restart of the electronic device.
[0061] Based on the correlation, the reference process is stored in the corresponding process set.
[0062] In some embodiments, the recovery module is specifically configured as follows:
[0063] Based on the invocation status of at least two target processes associated with the task to be processed, determine the cause of the abnormality that led to the abnormality in the electronic device;
[0064] Based on the aforementioned cause of the anomaly, a process to be processed is determined from the at least two target processes;
[0065] Based on the recovery strategy corresponding to the detection phase, the process to be processed is processed.
[0066] In some embodiments, the recovery module is further configured to:
[0067] If the abnormality exists in the first detection phase of the preset period, the pending process determined in the first detection phase is interrupted.
[0068] The first detection stage is the first detection stage of the preset cycle.
[0069] In some embodiments, the recovery module includes:
[0070] The storage module is configured to store the process information of the process to be processed determined in the first time unit when the anomaly exists in the first time unit of the second detection phase of the preset period; wherein the second detection phase is the detection phase following the first detection phase.
[0071] The processing module is configured to process the process to be processed determined by the second time unit based on a second comparison result between the process information of the process to be processed determined by the second time unit and the process information stored in the first time unit when the abnormality exists in the second time unit of the second detection stage.
[0072] The second time unit is sequentially continuous with the first time unit.
[0073] In some embodiments, the processing module is specifically configured as follows:
[0074] If the second comparison result indicates that the process information of the second time unit matches the process information of the first time unit, the electronic device is restarted.
[0075] In some embodiments, the processing module is further configured to:
[0076] If the second comparison result indicates that the process information of the second time unit does not match the process information of the first time unit, the process information stored in the first time unit is cleared.
[0077] If the abnormal duration reaches the first threshold, the pending process determined by the second time unit is interrupted;
[0078] Wherein, the first threshold is greater than the duration threshold corresponding to the second detection stage.
[0079] In some embodiments, the determining module is further configured to:
[0080] In response to entering the first detection phase of the preset period, if the duration of entering the first detection phase reaches a second threshold, the step of determining the task to be processed from the target task based on the first time interval is repeated until the second detection phase is entered from the first detection phase.
[0081] In response to entering the second detection phase, the step of determining the task to be processed from the target task based on the second time interval is repeated until the next preset cycle is entered;
[0082] The second time interval is greater than the first time interval.
[0083] According to a third aspect of the present disclosure, an electronic device is provided, comprising:
[0084] processor;
[0085] Memory used to store computer programs or instructions;
[0086] The processor executes the computer program or instructions to implement the steps in the processing method of any of the electronic devices described in the first aspect above.
[0087] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, comprising:
[0088] When the computer program or instructions in the storage medium are executed by a processor, the steps in the processing method of any of the electronic devices described in the first aspect are implemented.
[0089] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program or instructions, which, when executed by a processor, implement the steps in the processing method of any of the electronic devices described in the first aspect.
[0090] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects:
[0091] In this embodiment of the disclosure, based on the correlation between terminating the pending task and causing the electronic device to restart, and the positive correlation between the timing of the detection phase, the detection phase of the pending task that is less likely to cause the electronic device to restart is prioritized. Even if the electronic device is abnormal, the abnormality of the electronic device can be improved while reducing the loss of user data. Then, the detection phase of the pending task that is likely to cause the electronic device to restart is entered. Since the abnormality of the electronic device is determined to be higher in the later detection phase, restarting the electronic device can quickly and accurately restore the electronic device.
[0092] In this way, by setting different detection stages and recovering from any anomalies in each stage, not only can the stability of electronic equipment be improved, but also some data can be protected.
[0093] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0094] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0095] Figure 1 This is a flowchart illustrating a processing method of an electronic device according to an exemplary embodiment. Figure 1 ;
[0096] Figure 2 This is a flowchart illustrating a processing method of an electronic device according to an exemplary embodiment. Figure 2 ;
[0097] Figure 3 This is a flowchart illustrating a processing method of an electronic device according to an exemplary embodiment. Figure 3 ;
[0098] Figure 4 This is a flowchart illustrating a processing method of an electronic device according to an exemplary embodiment. Figure 4 ;
[0099] Figure 5 This is a block diagram illustrating an electronic device according to an exemplary embodiment;
[0100] Figure 6 This is a structural block diagram of an electronic device 600 according to an exemplary embodiment. Detailed Implementation
[0101] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0102] Figure 1 This is a flowchart illustrating a processing method of an electronic device according to an exemplary embodiment. Figure 1 ,like Figure 1 As shown, the processing method of this electronic device mainly includes the following steps:
[0103] In step 101, in response to entering any detection stage of a preset period, the task to be processed in the detection stage is determined from the target task based on the timing of the detection stage in the preset period; wherein the target task is created within the preset period, and the preset period includes at least two detection stages; each detection stage is sequentially continuous; the correlation between terminating the task to be processed and the restart of the electronic device is positively correlated with the timing of the detection stages.
[0104] In step 102, if it is determined that there is an anomaly in the electronic device based on the task to be processed, the anomaly is recovered based on the recovery strategy corresponding to the detection phase.
[0105] It should be noted that the processing method for electronic devices proposed in this disclosure can be applied to electronic devices. Here, the electronic device may include a terminal device, such as a mobile terminal or a fixed terminal. The mobile terminal may include devices such as mobile phones, tablets, laptops, and wearable electronic devices. The fixed terminal may include desktop computers, smart TVs, and in-vehicle systems. In some other embodiments, the processing method for electronic devices may also be applied to applications installed on the electronic device.
[0106] In other embodiments, the processing method of the electronic device in this disclosure can be configured within the electronic device, and this disclosure does not limit this. It should be noted that the execution entity of this disclosure can be the central processing unit (CPU) in the electronic device in hardware, and related background services in the electronic device in software, and this is not limited.
[0107] In one implementation, the user-space System Server Watchdog, or system service watchdog, runs within the system service process and is responsible for monitoring the responsiveness of critical system services. The watchdog's Handler Checker component periodically checks whether these system services have completed a heartbeat (monitor) operation within 60 seconds, and after the timeout, either kills the monitored process or triggers a container restart. On the one hand, the watchdog's 60-second reset time causes long user wait times, degrading the user experience; on the other hand, the watchdog only involves monitoring process restarts, not kernel restarts, thus failing to effectively recover from some abnormal scenarios, leading to performance degradation of electronic devices.
[0108] In this embodiment of the disclosure, a preset period including at least two detection stages is pre-set. In each detection stage, a task to be processed is determined from the target tasks created by the electronic device within the preset period. If the electronic device is found to be abnormal based on the task to be processed, the abnormality is recovered based on the recovery strategy corresponding to the detection stage. This reduces the situation where the electronic device cannot be detected in time, resulting in a long recovery time for the electronic device. As a result, the user's waiting time can be shortened and the user experience can be improved.
[0109] Here, electronic device malfunctions include, but are not limited to, malfunctions of devices such as mobile phones and computers, and malfunctions of in-vehicle infotainment systems. Types of electronic device malfunctions include: system freezes and / or application freezes. In some embodiments, system freezes and application freezes may occur in combination; a system freeze can cause an application freeze, but an application freeze does not cause a system freeze. Therefore, when a system freeze and application freeze occur in combination, resolving the system freeze issue can resolve the application freeze situation.
[0110] In this embodiment of the disclosure, the duration of the preset period can be set arbitrarily according to the requirements, for example, 0-120 seconds; the number of detection stages in the preset period can be set arbitrarily according to the requirements, as long as it is greater than or equal to two, for example, three detection stages.
[0111] It is understandable that when the various detection stages within a preset period are not sequential, there will be detection gaps. This means that anomalies during these gaps cannot be detected in a timely manner, leading to delayed recovery of electronic devices and impacting user experience. Therefore, the various detection stages within a preset period are sequential to improve the efficiency of detecting anomalies in electronic devices.
[0112] Here, when the electronic device system is in operation, it can enter a preset cycle to detect the target task created by the electronic device within that preset cycle. That is, entering the preset cycle can occur during the electronic device's operation phase, or during the electronic device's startup phase and operation phase.
[0113] It is understandable that the tasks to be processed are those that, among the target tasks created by the electronic device within a preset period, have a high probability of causing the electronic device to malfunction.
[0114] In some embodiments, system-critical tasks are components of the electronic device's operating system or system services, responsible for managing the system's basic functions, such as authentication tasks, key management tasks, or hardware management services; resource-dependent tasks are highly dependent on system resources (such as memory, CPU, disk I / O, etc.), such as high-rendering tasks and high-load tasks; process-related tasks depend on inter-process communication; if these tasks execute abnormally, they can easily cause malfunctions in the electronic device. Therefore, based on the type and execution parameters of the target tasks, system-critical tasks, resource-dependent tasks, and / or process-related tasks are identified from the target tasks, and these tasks are then designated as tasks to be processed.
[0115] In some embodiments, the System Server is a provider of basic services for the Android system and is a fundamental requirement for the operation of the Android system. Some services in the system reside in the System Server, such as the Window Manager Server (WMS), the Activity Manager SystemService (AMS), and the Package Manager Server (PMS). These services all exist as threads within the System Server process.
[0116] In other embodiments, a reference process that causes an abnormality in the electronic device during a preset usage process can be identified, and the progress information of the reference process can be stored in a preset list. During the current usage of the electronic device, the target task created by the electronic device is parsed to determine the process associated with the target task (i.e., the process called when executing the target task). Then, the process information of the process associated with the target task is compared with the progress information of the reference process. When it is determined that the process associated with the target task is any reference process, the target task is identified as a task to be processed. Here, the preset usage process includes, but is not limited to, the historical usage process of the electronic device, the pre-shipment testing process of the electronic device, the historical usage process of testing equipment of the same type as the electronic device, or the pre-shipment testing process of testing equipment of the same type as the electronic device.
[0117] For example, reference processes may include thermal management service processes, display service processes, and media service processes. Thermal management service processes manage the temperature and power consumption of electronic devices. When temperature sensors on the CPU, GPU, or other critical hardware components detect that the temperature exceeds a preset safety threshold, the system service invokes the thermal management service process. For instance, in high-load scenarios such as high-performance computing or gaming, the CPU temperature may rise rapidly, and once it reaches the safety threshold, the thermal management service process will be invoked.
[0118] The display service process manages the composition and display of screen content. When an application generates graphical content (such as a UI, animation, or video), the system service calls the display service process to composite and display the graphical content on the screen.
[0119] The Media Service process is used to manage multimedia resources and integrate multimedia services. For example, it can integrate the Audio Flinger service, the Media Player service, and the Camera service. When audio (such as music or notification sounds) needs to be played or sound (such as voice calls or recordings) needs to be recorded, the system service calls the Media Service process to complete the decoding, mixing, and output device management of the audio stream.
[0120] In other embodiments, in order to improve the accuracy of determining the task to be processed, given each reference process, the frequency of the reference process can be determined; and reference processes with a frequency greater than a preset frequency threshold can be stored in a preset list.
[0121] Here, once a task to be processed is identified, it can be used to determine whether the electronic device is malfunctioning. In some embodiments, the target process associated with the task to be processed is first determined; then the call state of the target process is determined; if the call state is abnormal, it is determined that the electronic device is malfunctioning. Here, the call state includes the process's call stack, thread states, or resource usage, etc.
[0122] In other embodiments, a time threshold corresponding to each detection stage is predetermined, and the communication duration of at least two target processes is determined from the call chain information when executing the task to be processed; wherein, the call chain information represents the link information of at least two target processes communicating based on an inter-process communication mechanism; and if any communication duration exceeds the duration threshold corresponding to the detection stage, it is determined that the electronic device is abnormal.
[0123] For example, by deducing the call chain information, it can be seen that the application layer calls the system service to support biometric identification; the system service calls the key service to encrypt and store the identified biometrics; and the key service calls the hardware security module (Trusted Execution Environment, TEE) to store the encrypted biometrics. When the communication duration between the system service and the key service exceeds the duration threshold corresponding to the detection phase, it is determined that the electronic device is abnormal.
[0124] In other embodiments, once each task to be processed is identified, each task to be processed can be stored in a preset list according to its acquisition time; and the tasks to be processed in the preset list can be deduplicated to obtain an updated preset list; then, based on the tasks to be processed in the updated preset list, it can be determined whether the electronic device is abnormal, thereby reducing the computational load of the electronic device and improving the efficiency of anomaly detection.
[0125] Here, the correlation between terminating pending tasks and causing electronic devices to restart is positively correlated with the timing of the detection phase. This can be understood as follows: when the correlation is low, the detection phase is determined to be earlier in the preset cycle; when the correlation is high, the detection phase is determined to be later in the preset cycle.
[0126] In this embodiment of the disclosure, during the detection phase where the timing precedes the detection phase, the termination operation of the determined task to be processed has a low correlation with the restart operation of the electronic device. Therefore, even if the electronic device is determined to be abnormal based on the task to be processed, the electronic device will not be restarted when the recovery strategy is performed, thereby ensuring the system stability of the electronic device while reducing the loss of user data.
[0127] In the detection phase that occurs later in the time sequence, the termination operation of the identified pending task is highly correlated with the restart operation of the electronic device. Furthermore, the degree of abnormality of the electronic device is positively correlated with the time of abnormality. That is, if the detection phase that occurs later in the time sequence determines that the degree of abnormality of the electronic device is high, then the electronic device can be restored based on the recovery strategy, causing the electronic device to restart, which can quickly and accurately restore the electronic device.
[0128] Here, terminating a pending task means forcibly ending the lifecycle of the pending task, releasing all resources, and the pending task cannot be resumed.
[0129] It is understandable that if an anomaly is determined to exist in the electronic device based on the task to be processed, the anomaly is recovered based on the recovery strategy corresponding to the detection phase.
[0130] Here, the recovery strategies for each detection stage can be the same or different. Taking the case where the recovery strategy is the same for each detection stage as an example, if an abnormality is determined to exist in the electronic device, the pending task can be terminated directly to recover from the abnormality; alternatively, the processes associated with the pending task can be interrupted to indirectly terminate the pending task and recover from the abnormality.
[0131] Taking the different recovery strategies for each detection stage as an example, for detection stages that occur earlier in the time sequence, the anomaly can be recovered by terminating the pending task or interrupting the process associated with the pending task; for detection stages that occur later in the time sequence, the anomaly can be recovered by restarting the electronic device.
[0132] In some embodiments, for each detection stage, if an anomaly is determined, the call status of at least two target processes associated with the task to be processed is determined; based on the call status of the at least two target processes, the cause of the anomaly is determined; and based on the cause of the anomaly, the process to be processed is determined from the at least two target processes; and then, based on the recovery strategy corresponding to the detection stage, the process to be processed is processed. In this way, by determining the root cause process of the anomaly, the electronic device can be quickly and accurately restored, effectively improving the user experience.
[0133] In some embodiments, the preset period is the detection period of the software watchdog. The watchdog detection period is set to at least two detection phases through software programming, with the detection time and recovery strategy for each phase defined. Furthermore, an anomaly occurring in a later detection phase can trigger a restart of the electronic device. This ensures timely recovery even in cases of Native Hang (or Native Layer Freeze) scenarios, thereby improving the stability of the electronic device. Here, Native Hang refers to a situation in the Android system where Native layer code causes threads or processes to become unresponsive for an extended period, resulting in an unrecoverable blocked state and impacting the system stability of the electronic device.
[0134] In this embodiment of the disclosure, based on the correlation between terminating the pending task and causing the electronic device to restart, and the positive correlation between the timing of the detection phase, the detection phase of the pending task that is less likely to cause the electronic device to restart is prioritized. Even if the electronic device is abnormal, the abnormality of the electronic device can be improved while reducing the loss of user data. Then, the detection phase of the pending task that is likely to cause the electronic device to restart is entered. Since the abnormality of the electronic device is determined to be higher in the later detection phase, restarting the electronic device can quickly and accurately restore the electronic device.
[0135] In this way, by setting different detection stages and recovering from any anomalies in each stage, not only can the stability of electronic equipment be improved, but also some data can be protected.
[0136] In some embodiments, based on the timing of the detection phase within a preset period, tasks to be processed in the detection phase are determined from the target tasks, including:
[0137] For each target task, identify the processes associated with that target task;
[0138] The processes associated with each target task are compared with the reference processes in the process set corresponding to the detection stage to obtain the first comparison result; wherein, each detection stage corresponds to a process set, and the degree of correlation between interrupting the reference processes in different process sets and the restart of the electronic device is different.
[0139] If the first comparison result indicates that there is a target process that matches any reference process in the process set, the target task corresponding to the target process is identified as the task to be processed.
[0140] Understandably, in order to improve the efficiency of identifying tasks to be processed, a set of processes corresponding to the detection phase can be obtained in advance. The process set contains reference processes with a relatively high probability of causing electronic devices to malfunction. By comparing the process associated with the target task with the reference process, it can be determined whether the target task is a task to be processed.
[0141] Here, each detection stage corresponds to a process set. When there are two detection stages, each detection stage corresponds to a different process set; while when there are at least three detection stages, each detection stage in the preset period corresponds to a different process set, or the first detection stage and the second detection stage in the preset period can correspond to the same process set, and the third detection stage in the preset period corresponds to a process set different from the first detection stage, or the second detection stage and the third detection stage correspond to the same process set, but different from the process set of the first detection stage.
[0142] In some embodiments, reference processes that historically caused electronic device malfunctions are obtained, and the correlation between interrupted reference processes and processes that caused the electronic device to restart is determined. When the correlation is greater than a first threshold, the reference processes are determined to be the set of processes corresponding to earlier detection stages. When the correlation is less than or equal to the first threshold, the reference processes are determined to be the set of processes corresponding to later detection stages. Multiple thresholds can be set as needed.
[0143] Here, the process associated with the target task can be understood as the process invoked when the target task is executed. For example, if the target task is a network service discovery task or a network event listening task, the associated process can be a network daemon process; as another example, if the target task is a battery life optimization task or a game mode optimization task, the associated process can be a service process related to the Hardware Abstraction Layer (HAL).
[0144] In some embodiments, in order to improve the accuracy of determining the process associated with the target task, call chain information when the target task is executed can be obtained, wherein the call chain information represents the link information of at least two target processes communicating based on the inter-process communication mechanism; then the call chain information is deduced to obtain the complete inter-process communication link; then the receiving end of each level of the communication link is determined as the process associated with the target task.
[0145] In this embodiment of the disclosure, when the process associated with the target task is determined, the associated process is compared with each reference process in the process set corresponding to the detection stage to obtain a first comparison result; the first comparison result indicates that the associated process matches the reference process, and the target task is determined to be a task to be processed.
[0146] In some embodiments, a similarity threshold can be preset to determine the similarity between the process information of an associated process and the process information of each reference process; if any similarity is greater than or equal to the similarity threshold, the process can be identified as the target process; and the target task corresponding to the target process can be identified as the task to be processed. Here, the similarity threshold can be set arbitrarily.
[0147] In this embodiment of the disclosure, in each detection stage, the process associated with the target task is compared with the reference process in the process set corresponding to the detection stage. This can improve the accuracy of determining the task to be processed in that detection stage, thereby enabling hierarchical detection and improving the efficiency of restoring electronic devices.
[0148] In some embodiments, methods for determining that an electronic device is malfunctioning based on a pending task include:
[0149] The communication duration of at least two target processes is determined from the call chain information during the execution of the pending task; wherein, the call chain information represents the link information of communication between at least two target processes based on the inter-process communication mechanism;
[0150] If the duration of any communication exceeds the duration threshold corresponding to the detection phase, it is determined that the electronic device is abnormal; wherein, each detection phase corresponds to a duration threshold.
[0151] Here, the inter-process communication mechanism Binder is used to enable communication between processes. For example, when a system process needs to access the capabilities of another process, it will use the Binder mechanism to call that other process, thus achieving communication between the system process and other processes.
[0152] For example, in the Android system, system services can act as clients in the binder call chain in scenarios such as cross-system service calls, hardware abstraction layer (HAL) interactions, system-level function implementation, and key management. For instance, when AMS manages the application lifecycle, it uses binder to call PMS to query application package information, permissions, etc. When an application requests sensor data, the sensor service calls the HAL binder interface to obtain raw data from the accelerometer, gyroscope, etc. When displaying a notification, the notification management service uses binder to call the status bar management service, passing the notification's icon, title, content, and other information for display in the status bar. When it's necessary to generate, store, or use encryption keys (such as for device encryption, file encryption, or secure communication), the system service uses binder to call the key service.
[0153] In this embodiment of the disclosure, the call chain information when executing the task to be processed can be deduced to obtain the complete path information of the two target processes based on binder communication.
[0154] For example, the task to be processed is a multimedia pipeline task, such as playing an encrypted video. By inferring from the call chain information, it can be seen that the application layer calls the system service to manage the playback status; the system service calls the decapsulation media file service to parse the encrypted video; the decapsulation media file service calls the encoding / decoding media file service to decode the decrypted video through a hardware decoder; and the encoding / decoding media file service calls the display service to display the video.
[0155] In another example, the task to be processed is to store sensitive data, such as saving biometrics (i.e., facial information, fingerprint information). By deducing the call chain information, it can be seen that the application layer calls the system service to support biometric recognition; the system service calls the key service to encrypt the recognized biometrics; and the storage key service calls the hardware security module to store the encrypted biometrics.
[0156] Here, the duration threshold for each detection stage can be set according to requirements, such as 20 seconds, 40 seconds, or 50 seconds.
[0157] Meanwhile, each detection stage corresponds to a duration threshold. When there are two detection stages, each detection stage corresponds to a different duration threshold; while when there are at least three detection stages, each detection stage in the preset period corresponds to a different duration threshold, or the first detection stage and the second detection stage in the preset period can correspond to the same duration threshold, and the third detection stage in the preset period corresponds to a different duration threshold than the first detection stage, or the second detection stage and the third detection stage correspond to the same duration threshold, but are different from the duration threshold of the first detection stage.
[0158] It should be noted that by pre-determining the duration threshold corresponding to the detection phase, for each task to be processed, if any communication duration exceeds the duration threshold corresponding to the detection phase, it is determined that the electronic device is abnormal, thereby improving the efficiency of determining whether the electronic device is abnormal.
[0159] For example, the communication duration corresponding to the task to be processed is: the communication duration between the system service and the decapsulation media file service, the communication duration between the decapsulation media file service and the encoding / decoding media file service, and the communication duration between the encoding / decoding media file service and the display service. When any of these communication durations exceeds the duration threshold corresponding to the detection phase, it is determined that the electronic device is abnormal.
[0160] In this embodiment of the disclosure, the communication duration of at least two target processes is determined from the call chain information, and the presence of anomalies in the electronic device is determined based on the communication duration and the duration threshold corresponding to the detection phase. This improves the efficiency of determining whether an electronic device is abnormal, thereby improving the accuracy of executing the recovery strategy.
[0161] Figure 2 This is a flowchart illustrating a processing method of an electronic device according to an exemplary embodiment. Figure 2 ,like Figure 2 As shown, the processing method of this electronic device mainly includes the following steps:
[0162] In step 201, the reference process that caused the electronic device to malfunction is determined, and the correlation between the interruption operation on the reference process and the restart of the electronic device is determined.
[0163] In step 202, the reference process is stored in the corresponding process set based on the correlation degree.
[0164] In step 203, the processes associated with each target task are compared with the reference processes in the process set corresponding to the detection phase to obtain the first comparison result. If the first comparison result indicates that there is a target process that matches any reference process in the process set, the target task corresponding to the target process is determined as the task to be processed.
[0165] In step 204, if it is determined that there is an anomaly in the electronic device based on the task to be processed, the anomaly is recovered based on the recovery strategy corresponding to the detection phase.
[0166] Here, the reference process can be determined based on historical abnormal events of electronic devices or on engineering experience.
[0167] Understandably, in order to improve the accuracy of constructing the process sets corresponding to each detection stage, we can first obtain the reference process that caused the electronic device to restart; then determine the correlation between the interrupted reference process and the restart of the electronic device; and based on the correlation, store the reference process in the corresponding process set.
[0168] In some embodiments, reference processes can be stored in a corresponding process set during the testing phase of the electronic device. Here, the testing phase can be understood as any stage before the electronic device leaves the factory, such as the research and development phase, the verification phase, or the user scenario testing phase.
[0169] In some embodiments, an initial process set can be obtained by pre-setting an empty set; then, reference processes are stored in the corresponding initial process set based on the correlation degree to obtain a process set. Since the correlation degree between terminating the pending task and the restart of the electronic device is positively correlated with the timing of the detection phase, after obtaining each process set, the correlation relationship between each detection phase and each process set can be established based on the correlation degree corresponding to the reference processes in each process set, thereby obtaining the process set corresponding to different detection phases.
[0170] For example, during the testing phase of an electronic device, when interrupting a reference process causes the electronic device to restart, the reference process can be stored in a certain process set to obtain the process set corresponding to the later detection phase, so as to facilitate the post-processing of pending tasks that are likely to cause the electronic device to restart; while when interrupting the reference process does not cause the electronic device to restart, the reference process can be stored in another process set to obtain the process set corresponding to the earlier detection phase, so as to prioritize the processing of pending tasks that are unlikely to cause the electronic device to restart, thereby improving the system stability of the electronic device while reducing the possibility of user data loss.
[0171] Another example involves determining the cumulative number of times an interruption of the reference process causes the electronic device to restart. When the cumulative number is greater than or equal to a preset threshold, it is determined that the correlation between interrupting the reference process and restarting the electronic device is relatively high. In this case, the reference process is stored in a certain process set to obtain the process set corresponding to the later detection stage. Conversely, when the cumulative number is less than the preset threshold, it is determined that the correlation between interrupting the reference process and restarting the electronic device is relatively low. In this case, the reference process is stored in another process set to obtain the process set corresponding to the earlier detection stage. This reduces randomness and improves the accuracy of constructing the process set corresponding to the detection stage. Here, the preset threshold can be set arbitrarily according to requirements.
[0172] In other embodiments, in order to improve the accuracy of the process set corresponding to the detection stage, the process set corresponding to each detection stage can be updated periodically based on cloud data or the processes that cause the electronic device to malfunction at any detection stage. This can provide data support for subsequent optimization and enable the electronic device to respond to abnormal situations more quickly.
[0173] For example, the process set corresponding to the detection stage with the earlier timing can be Record2, and the process set corresponding to the detection stage with the later timing can be Record1.
[0174] The reference processes in Record2 include, but are not limited to: (1) audio and video service process; (2) Qualcomm hardware abstraction layer service process; (3) multimedia service process; (4) key service process; (5) camera management process; (6) hardware abstraction layer service process; (7) multiple hardware abstraction layer service process; (8) multimedia service process based on the next-generation codec framework; (9) security service process; (10) specific hardware function daemon process; (11) specific vehicle-mounted Internet service process; and (12) specific key management service process. The reference processes in Record1 include, but are not limited to: (1) display service process; (2) network device daemon process; (3) key management service process; (4) thermal management service process; (5) hardware abstraction layer service process; and (6) specific graphics process.
[0175] In this embodiment, storing reference processes in the corresponding process set based on correlation helps the electronic device accurately identify and handle different types of target processes, effectively improving recovery efficiency. Simultaneously, during the actual testing phase of the electronic device, the reference processes in the process set can be updated periodically, providing data support for subsequent optimization. This enables the electronic device to respond more quickly to anomalies, reduces the risk of system crashes, ensures stable system operation, and ultimately improves user experience.
[0176] In some embodiments, anomaly recovery is performed based on the recovery strategy corresponding to the detection phase, including:
[0177] Based on the call states of at least two target processes associated with the task to be processed, determine the cause of the abnormality that led to the abnormality of the electronic device;
[0178] Based on the cause of the anomaly, determine the process to be processed from at least two target processes;
[0179] Based on the recovery strategy corresponding to the detection phase, the process to be processed is handled.
[0180] It should be noted that simply restarting the electronic device to recover from an anomaly lacks flexible judgment of the cause of the anomaly and cannot specifically handle the anomaly scenario, which can easily lead to data loss. Therefore, in this embodiment of the disclosure, by first determining the cause of the anomaly, then determining the process to be processed, and then processing the process to be processed in a targeted manner, the accuracy of the recovery strategy can be improved, thereby achieving the effect of protecting user data.
[0181] Here, the call status includes, but is not limited to, the process's call stack, thread status, or resource usage. Reasons for exceptions include, but are not limited to, prolonged inter-process execution, inter-process deadlock, thread pool fullness, intra-process deadlock, or service call blocking.
[0182] For example, excessive processing time during communication due to resource contention, synchronization blocking, or computationally intensive tasks can cause prolonged inter-process latency, leading to malfunctions in electronic devices. Therefore, when timeout warnings are present in the binder logs, the cause of the malfunction is determined to be prolonged inter-process latency.
[0183] When two or more target processes are in a loop waiting for each other to release resources, causing a complete halt in communication, a deadlock occurs, leading to malfunctions in electronic devices. Therefore, when the thread status in the binder log shows as blocked, or when the log directly displays "deadlock detected," the cause of the malfunction is determined to be an inter-process deadlock.
[0184] When the number of active threads in the thread pool reaches the maximum pool size and the work queue is full, newly submitted tasks will be rejected or blocked, causing electronic devices to malfunction. Therefore, when rejection information is displayed in the logs, or when the call stack shows characteristics such as blocking, waiting, or task backlog, the cause of the malfunction is determined to be a full thread pool.
[0185] In this embodiment of the disclosure, when the cause of the anomaly is determined, the process to be processed can be determined from each target process based on the cause of the anomaly, so as to restore the electronic device in a targeted manner, reduce the situation of invalid restoration of the electronic device, and thus improve the restoration accuracy.
[0186] Specifically, when the call chain information of the task to be processed is a first-level call chain information, if the process that triggered the exception is the process that provides services or functions in the first-level call chain information, then the receiving process is determined as the process to be processed; while when the call chain information of the task to be processed is a multi-level call chain information, the target process that is more closely related to the exception reason is determined as the process to be processed.
[0187] For example, if the cause of the exception is long inter-process time consumption, the target process causing the blockage is identified as the process to be processed; if the cause of the exception is inter-process deadlock, all target processes on the deadlock loop are identified as processes to be processed; if the cause of the exception is a full thread pool, the target process that is called the most times is identified as the process to be processed.
[0188] Here, the recovery strategies for different detection stages can be the same or different. For example, the recovery strategy for both the detection stage that occurs earlier and the detection stage that occurs later can be to interrupt the pending process; or, for another example, the recovery strategy for the detection stage that occurs earlier can be to interrupt the pending process, while the recovery strategy for the detection stage that occurs later can be to restart the electronic device.
[0189] In this embodiment of the disclosure, the cause of the electronic device malfunction is first traced; then, the process to be processed is determined based on the cause of the malfunction; finally, the process to be processed is processed based on the recovery strategy corresponding to the detection stage, thereby improving the accuracy of electronic device recovery and reducing data loss.
[0190] In some embodiments, the process to be processed is handled based on the recovery strategy corresponding to the detection phase, including:
[0191] If an anomaly is found in the first detection phase of the preset cycle, the pending process determined in the first detection phase will be interrupted.
[0192] The first detection stage is the first detection stage within the preset cycle.
[0193] Understandably, the first detection phase is the first detection phase within a preset cycle. The probability of interrupting the process identified in the first detection phase, leading to a restart of the electronic device, is low. Therefore, if an anomaly is detected in the first detection phase, the process is directly interrupted.
[0194] Here, when the operating system kernel of an electronic device executes a termination signal, it can interrupt the pending process.
[0195] In this embodiment of the disclosure, the correlation between the process to be processed determined in the first detection stage and the restart of the electronic device is low. When the electronic device malfunctions in the first detection stage, the process to be processed can be directly interrupted, which can not only specifically restore the frozen device, but also protect user data, thereby improving the intelligence of the electronic device.
[0196] In some embodiments, the process to be processed is handled based on the recovery strategy corresponding to the detection phase, including:
[0197] If an anomaly is found in the first time unit of the second detection phase within a preset period, the process information of the process to be processed determined by the first time unit is stored; wherein, the second detection phase is the detection phase following the first detection phase;
[0198] If an anomaly is found in the second time unit of the second detection phase, the process to be processed determined by the second time unit is processed based on the second comparison result between the process information of the process to be processed determined by the second time unit and the process information stored in the first time unit.
[0199] The second time unit is sequentially continuous with the first time unit.
[0200] It should be noted that the second detection stage is used to detect pending tasks that are likely to cause electronic devices to restart. Two consecutive time units can be set in the second detection stage, and the process information of the pending processes determined in the two time units can be obtained. Based on the second comparison result of the process information of the two time units, the pending processes determined in the second time unit are processed, thereby reducing the possibility of user data loss due to the randomness of anomaly detection.
[0201] Here, the duration of the two time units can be the same or different. For example, when the second detection phase is 60 seconds to 120 seconds, the first time unit can be 60 seconds and the second time unit can be 61 seconds to 120 seconds; or the first time unit can be 60 seconds to 90 seconds and the second time unit can be 91 seconds to 120 seconds.
[0202] In this embodiment of the present disclosure, when there is an anomaly in the first time unit, the process information of the process to be processed determined by the first time unit can be stored so as to determine the second comparison result when there is also an anomaly in the second time unit.
[0203] Here, the process information can be a process identifier, and the similarity between the process identifier stored in the first time unit and the process identifier determined in the second time unit is determined; the second comparison result is determined based on the similarity.
[0204] In some embodiments, when the second comparison result indicates that the processes to be processed determined by the two time units are the same process, the electronic device is restarted; and when the second comparison result indicates that the processes to be processed determined by the two time units are different processes, the electronic device is not restarted, and the abnormal duration of the electronic device is obtained.
[0205] In this embodiment of the disclosure, considering that the process to be processed determined in the interruption second detection stage has a high correlation with the restart of the electronic device, the second detection stage is divided into a first time unit and a second time unit. Based on the matching degree of the process information of the process to be processed determined in the two time units, a recovery strategy is executed, thereby reducing the randomness of anomaly detection, improving the accuracy of restarting the electronic device, and reducing the possibility of user data loss.
[0206] In some embodiments, the process to be processed determined by the second time unit is processed based on a second comparison result between the process information of the process to be processed determined by the second time unit and the process information stored in the first time unit, including:
[0207] If the second comparison result indicates that the process information of the second time unit matches the process information of the first time unit, the electronic device is restarted.
[0208] Here, when the second comparison result indicates that the process information of the second time unit matches the process information of the first time unit, it is determined that the abnormal detection of the electronic device in the second detection stage is not accidental, and the process that causes the continuous abnormality of the electronic device is the same process. Then the electronic device can be restarted to accurately and quickly restore the electronic device, thereby improving the user experience.
[0209] In some embodiments, a preset similarity threshold is used to determine the similarity between the process information of the second time unit and the process information of the first time unit; if the determined similarity is greater than or equal to the similarity threshold, it is determined that the process information of the second time unit matches the process information of the first time unit; and if the determined similarity is less than the similarity threshold, it is determined that the process information of the second time unit does not match the process information of the first time unit.
[0210] In this embodiment of the disclosure, when the process information of the processes to be processed determined in two time units matches, it is determined that there is no randomness in the abnormal detection of the second detection stage, and then the electronic device is directly restarted to accurately and quickly restore the electronic device.
[0211] In some embodiments, the process to be processed determined by the second time unit is processed based on a second comparison result between the process information of the process to be processed determined by the second time unit and the process information stored in the first time unit, including:
[0212] If the second comparison result indicates that the process information of the second time unit does not match the process information of the first time unit, the process information stored in the first time unit is cleared.
[0213] If the abnormal duration reaches the first threshold, the pending process determined by the second time unit is interrupted.
[0214] The first threshold is greater than the duration threshold corresponding to the second detection stage.
[0215] Here, if the process information in the second time unit does not match the process information in the first time unit, it is determined that the abnormal detection of the electronic device may be accidental, or the process that causes the electronic device to continue to malfunction is not the same process. In order to improve the protection of user data, the electronic device may not be directly restarted.
[0216] Understandably, if an anomaly occurs in the first time unit, the process information of the processes to be processed is stored. Therefore, in order to reduce memory usage, if the process information in the second time unit does not match the process information in the first time unit, the stored process information is cleared first.
[0217] It should be noted that, considering that the electronic device in the second time unit may still be abnormal, directly restarting the electronic device would result in the loss of user data. Therefore, a first threshold greater than the duration threshold corresponding to the second detection stage can be set, and the pending process determined by the second time unit can be interrupted when the abnormal duration reaches the first threshold.
[0218] Here, the first threshold can be set arbitrarily according to the requirements, as long as it is greater than the duration threshold corresponding to the second detection stage. For example, if the duration threshold corresponding to the second detection stage is 60 seconds, then the first threshold can be 62 seconds.
[0219] In this embodiment of the disclosure, when the process information of the processes to be processed determined by the two time units does not match, it is determined that the abnormal detection in the second detection stage may be accidental. Therefore, the process information stored in the first time unit is cleared first; and when the abnormal duration reaches the first threshold, the processes to be processed determined by the second time unit are interrupted to reduce the situation of invalid restarting of electronic devices and reduce the situation of user data loss.
[0220] Figure 3 This is a flowchart illustrating a processing method of an electronic device according to an exemplary embodiment. Figure 3 ,like Figure 3 As shown, the processing method of this electronic device mainly includes the following steps:
[0221] In step 301, in response to entering the first detection phase of the preset period, if the duration of entering the first detection phase reaches the second threshold, the step of determining the task to be processed from the target task based on the first time interval is repeated until the second detection phase is entered from the first detection phase.
[0222] In step 302, if it is determined that there is an anomaly in the electronic device based on the task to be processed, the anomaly is recovered based on the recovery strategy corresponding to the first detection stage.
[0223] In step 303, in response to entering the second detection phase, the step of determining the task to be processed from the target task based on the second time interval is repeated until the next preset cycle is entered; wherein the second time interval is greater than the first time interval.
[0224] In step 304, if it is determined that there is an anomaly in the electronic device based on the task to be processed, the anomaly is recovered based on the recovery strategy corresponding to the second detection stage.
[0225] It is understandable that, considering the special circumstances of frequent restarts of electronic devices and / or invalid determination of pending tasks during the use of electronic devices, i.e., short inter-process communication time will not cause the electronic device to malfunction, a second threshold can be set, and the anomaly detection of the first detection stage can be triggered when the duration of entering the first detection stage reaches the second threshold.
[0226] Here, the second threshold can be set according to needs, such as 10 seconds, to filter out special cases where electronic devices frequently restart.
[0227] Meanwhile, the second threshold can also be determined based on the duration threshold corresponding to the first detection stage. This allows for filtering out some special cases while reducing invalid determinations of pending tasks, thus improving anomaly detection accuracy. For example, when the duration threshold corresponding to the first detection stage is 20 seconds, the second threshold can be 20 seconds, or the second threshold can be 25 seconds.
[0228] In this embodiment of the disclosure, in response to the anomaly detection that triggers the first detection stage, the process associated with each target task can be repeatedly executed based on a first time interval, and compared with the reference process in the process set corresponding to the first detection stage to obtain a first comparison result, and the task to be processed can be determined based on the first comparison result, until the second detection stage is entered.
[0229] In response to entering the second detection phase, the processes associated with each target task based on the second time interval can be repeatedly executed, and compared with the reference processes in the process set corresponding to the second detection phase to obtain the first comparison result. Based on the first comparison result, the steps of the task to be processed are determined until the next preset cycle is entered.
[0230] Here, the first time interval and the second time interval can be set arbitrarily according to the requirements, as long as the second time interval is greater than the first time interval. For example, the first time interval is 20 seconds and the second time interval is 45 seconds.
[0231] Meanwhile, the next preset cycle is the cycle following the current preset cycle.
[0232] In some embodiments, in response to entering the second detection phase, the target task created by the electronic device in the first detection phase and filtered out in the first detection phase can be obtained first; the process associated with the target task can be compared with the reference process in the process set corresponding to the second detection phase to obtain a first comparison result, and the task to be processed corresponding to the first time unit of the second detection phase can be determined based on the first comparison result; then the steps of comparing the process associated with the target task created by the electronic device in the second detection phase with the reference process in the process set corresponding to the second detection phase based on the second time interval to obtain the first comparison result and determining the task to be processed based on the first comparison result can be repeated until the next preset cycle is entered.
[0233] In this embodiment, setting a second threshold in the first detection stage can filter out some special cases while reducing the number of invalid task determinations. Repeating the step of determining tasks from the target tasks based on a first time interval improves the efficiency of anomaly detection in the first detection stage, thereby enhancing the stability of the electronic device system. Similarly, in the second detection stage, repeating the step of determining tasks from the target tasks based on a second time interval further improves the efficiency of anomaly detection, thus enhancing the stability of the electronic device system.
[0234] Figure 4 This is a flowchart illustrating a processing method of an electronic device according to an exemplary embodiment. Figure 4 ,like Figure 4 As shown, the processing method of this electronic device mainly includes the following steps:
[0235] In step 401, in response to entering any detection phase of a preset period, the target task created by the electronic device within the preset period is acquired.
[0236] In step 402, for each target task, the process associated with the target task is determined.
[0237] In step 403, the processes associated with each target task are compared with the reference processes in the process set corresponding to the detection stage to obtain the first comparison result; wherein, each detection stage corresponds to a process set, and the degree of association between interrupting the reference processes in different process sets and the restart of the electronic device is different.
[0238] In step 404, it is determined whether the first comparison result indicates the existence of a target process that matches any of the reference processes in the process set.
[0239] In some embodiments, if it is determined that the first comparison result indicates the existence of a target process that matches any reference process in the process set, step 405 is performed.
[0240] In other embodiments, if the first comparison result indicates that there is no target process that matches any reference process in the process set, step 406 is executed and the process ends.
[0241] Here, if the first application is not in the preset list, the first task is kept in the first scheduling group, and there is no need to perform a frequency increase operation.
[0242] In step 405, the task to be processed corresponding to the target process and the call chain information for executing the task to be processed are determined.
[0243] In some embodiments, in response to entering a first detection phase with a preset period, if the duration of entering the first detection phase reaches a second threshold, the process associated with each target task based on a first time interval can be repeatedly executed, compared with the reference process in the process set corresponding to the first detection phase, to obtain a first comparison result, and the task to be processed can be determined based on the first comparison result, until the second detection phase is entered.
[0244] In other embodiments, in response to entering the second detection phase of a preset period, the process associated with each target task based on the second time interval can be repeatedly executed, and compared with the reference process in the process set corresponding to the second detection phase to obtain a first comparison result. Based on the first comparison result, the task to be processed is determined until the next preset period is entered. The second time interval is greater than the first time interval.
[0245] In step 406, it is determined that no abnormality occurred in the electronic device during the detection phase.
[0246] In step 407, it is determined whether the communication duration indicated by the call chain information is greater than the duration threshold corresponding to the detection phase.
[0247] In some embodiments, if it is determined that the communication duration indicated by the call chain information is greater than the duration threshold corresponding to the detection phase, step 408 is performed.
[0248] In other embodiments, step 406 is performed if it is determined that the communication duration indicated by the call chain information is less than or equal to the duration threshold corresponding to the detection phase.
[0249] In step 408, it is determined that the electronic device malfunctioned during the detection phase.
[0250] In step 409, the cause of the abnormality that caused the electronic device to malfunction is determined based on the call status of at least two target processes associated with the task to be processed.
[0251] In step 410, based on the cause of the anomaly, the process to be processed is determined from at least two target processes.
[0252] In step 411, the process to be processed is processed based on the recovery strategy corresponding to the detection phase.
[0253] In some embodiments, if an anomaly is found in the first detection phase of a preset period, the pending process determined in the first detection phase is interrupted; wherein, the first detection phase is the first detection phase of the preset period.
[0254] In other embodiments, if an anomaly is found in the first time unit of the second detection phase within a preset period, the process information of the process to be processed determined by the first time unit is stored; wherein, the second detection phase is the detection phase following the first detection phase; if an anomaly is found in the second time unit of the second detection phase, and the second comparison result indicates that the process information of the second time unit matches the process information of the first time unit, the electronic device is restarted; wherein, the second time unit and the first time unit are sequentially continuous.
[0255] In other embodiments, if the second comparison result indicates that the process information of the second time unit does not match the process information of the first time unit, the process information stored in the first time unit is cleared; if the abnormal duration reaches a first threshold, the process to be processed determined by the second time unit is interrupted; wherein, the first threshold is greater than the duration threshold corresponding to the second detection stage.
[0256] In this embodiment of the disclosure, based on the correlation between terminating the pending task and causing the electronic device to restart, and the positive correlation between the timing of the detection phase, the detection phase of the pending task that is less likely to cause the electronic device to restart is prioritized. Even if the electronic device is abnormal, the abnormality of the electronic device can be improved while reducing the loss of user data. Then, the detection phase of the pending task that is likely to cause the electronic device to restart is entered. Since the abnormality of the electronic device is determined to be higher in the later detection phase, restarting the electronic device can quickly and accurately restore the electronic device.
[0257] In this way, by setting different detection stages and recovering from any anomalies in each stage, not only can the stability of electronic equipment be improved, but also some data can be protected.
[0258] Figure 5 This is a block diagram illustrating an electronic device according to an exemplary embodiment, such as... Figure 5 As shown, electronic device 500 includes:
[0259] The determination module 501 is configured to, in response to entering any detection stage of a preset period, determine the pending task of the detection stage from the target tasks based on the timing of the detection stage within the preset period; wherein the target task is created within the preset period, and the preset period includes at least two detection stages; each detection stage is sequentially consecutive; the correlation between terminating the pending task and restarting the electronic device is positively correlated with the timing of the detection stages;
[0260] The recovery module 502 is configured to recover from the abnormality based on the recovery strategy corresponding to the detection phase when it is determined that the electronic device has an abnormality based on the task to be processed.
[0261] In some embodiments, the determining module 501 is specifically configured as follows:
[0262] For each of the target tasks, determine the process associated with the target task;
[0263] The processes associated with each of the target tasks are compared with the reference processes in the process set corresponding to the detection stage to obtain a first comparison result; wherein, each detection stage corresponds to a process set, and the degree of association between interrupting the reference processes in different process sets and the restart of the electronic device is different;
[0264] If the first comparison result indicates that there is a target process that matches any reference process in the process set, the target task corresponding to the target process is determined as the task to be processed.
[0265] In some embodiments, the device 500 further includes:
[0266] The anomaly detection module is configured to determine the communication duration of at least two target processes from the call chain information when the task to be processed is executed; wherein, the call chain information represents the link information of the communication between the at least two target processes based on the inter-process communication mechanism;
[0267] If the duration of any of the communication sessions exceeds the duration threshold corresponding to the detection phase, it is determined that the electronic device has the anomaly; wherein each detection phase corresponds to a duration threshold.
[0268] In some embodiments, the device 500 further includes:
[0269] The generation module is configured to determine a reference process that causes the electronic device to malfunction, and to determine the correlation between an interruption operation on the reference process and a restart of the electronic device.
[0270] Based on the correlation, the reference process is stored in the corresponding process set.
[0271] In some embodiments, the recovery module 502 is specifically configured as follows:
[0272] Based on the invocation status of at least two target processes associated with the task to be processed, determine the cause of the abnormality that led to the abnormality in the electronic device;
[0273] Based on the aforementioned cause of the anomaly, a process to be processed is determined from the at least two target processes;
[0274] Based on the recovery strategy corresponding to the detection phase, the process to be processed is processed.
[0275] In some embodiments, the recovery module 502 is further configured to:
[0276] If the abnormality exists in the first detection phase of the preset period, the pending process determined in the first detection phase is interrupted.
[0277] The first detection stage is the first detection stage of the preset cycle.
[0278] In some embodiments, the recovery module 502 includes:
[0279] The storage module is configured to store the process information of the process to be processed determined in the first time unit when the anomaly exists in the first time unit of the second detection phase of the preset period; wherein the second detection phase is the detection phase following the first detection phase.
[0280] The processing module is configured to process the process to be processed determined by the second time unit based on a second comparison result between the process information of the process to be processed determined by the second time unit and the process information stored in the first time unit when the abnormality exists in the second time unit of the second detection stage.
[0281] The second time unit is sequentially continuous with the first time unit.
[0282] In some embodiments, the processing module is specifically configured as follows:
[0283] If the second comparison result indicates that the process information of the second time unit matches the process information of the first time unit, the electronic device is restarted.
[0284] In some embodiments, the processing module is further configured to:
[0285] If the second comparison result indicates that the process information of the second time unit does not match the process information of the first time unit, the process information stored in the first time unit is cleared.
[0286] If the abnormal duration reaches the first threshold, the pending process determined by the second time unit is interrupted;
[0287] Wherein, the first threshold is greater than the duration threshold corresponding to the second detection stage.
[0288] In some embodiments, the determining module 501 is further configured to:
[0289] In response to entering the first detection phase of the preset period, if the duration of entering the first detection phase reaches a second threshold, the step of determining the task to be processed from the target task based on the first time interval is repeated until the second detection phase is entered from the first detection phase.
[0290] In response to entering the second detection phase, the step of determining the task to be processed from the target task based on the second time interval is repeated until the next preset cycle is entered;
[0291] The second time interval is greater than the first time interval.
[0292] Regarding the electronic devices in the above embodiments, the specific ways in which each module performs operations have been described in detail in the embodiments related to the method, and will not be elaborated here.
[0293] Figure 6This is a structural block diagram illustrating an electronic device 600 according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0294] Reference Figure 6 The electronic device 600 may include one or more of the following components: processing component 602, memory 604, power supply component 606, multimedia component 608, audio component 610, input / output (I / O) interface 612, sensor component 614, and communication component 616.
[0295] Processing component 602 typically controls the overall operation of electronic device 600, such as operations associated with at least one of display, telephone call, data communication, camera operation, and recording operation. Processing component 602 may include one or more processors 620 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 602 may include one or more modules to facilitate interaction between processing component 602 and other components. For example, processing component 602 may include a multimedia module to facilitate interaction between multimedia component 608 and processing component 602.
[0296] Memory 604 is configured to store various types of data to support the operation of electronic device 600. Examples of such data include at least one of the following: instructions for any application or method operating on electronic device 600, contact data, phonebook data, messages, pictures, and videos. Memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0297] Power supply component 606 provides power to various components of electronic device 600. Power supply component 606 may include at least one of the following: a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 600.
[0298] Multimedia component 608 includes a screen that provides an output interface between electronic device 600 and user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a Touch Panel, the screen may be implemented as a touchscreen to receive input signals from the user. The Touch Panel includes one or more touch sensors to sense touches, swipes, and gestures on the Touch Panel. The touch sensors may sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 608 includes a front-facing camera and / or a rear-facing camera. When electronic device 600 is in an operating mode, such as a shooting mode or video mode, the front-facing camera and / or rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0299] Audio component 610 is configured to output and / or input audio signals. For example, audio component 610 includes a microphone (MIC) configured to receive external audio signals when electronic device 600 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 604 or transmitted via communication component 616. In some embodiments, audio component 610 also includes a speaker for outputting audio signals.
[0300] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, and buttons. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0301] Sensor assembly 614 includes one or more sensors for providing state assessments of various aspects of electronic device 600. For example, sensor assembly 614 may detect the on / off state of electronic device 600, the relative positioning of components such as the display and keypad of electronic device 600, changes in position of electronic device 600 or one of its components, the presence or absence of user contact with electronic device 600, orientation or acceleration / deceleration of electronic device 600, and temperature changes of electronic device 600. Sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 614 may also include an optical sensor, such as a complementary metal-oxide-semiconductor (CMOS) or charge-coupled device (CCD) image sensor, for use in imaging applications. In some embodiments, sensor assembly 614 may also include, but is not limited to, at least one of the following: an accelerometer, a gyroscope, a magnetometer, a pressure sensor, and a temperature sensor.
[0302] Communication component 616 is configured to facilitate wired or wireless communication between electronic device 600 and other devices. Electronic device 600 can access wireless networks based on communication standards, such as Wi-Fi, 4G, 5G, or combinations thereof. In one exemplary embodiment, communication component 616 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 616 also includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID), Infrared Data Association (IrDA), Ultra Wide Band (UWB), Bluetooth (BT), and other technologies.
[0303] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components.
[0304] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including executable instructions or a computer program, which can be executed by a processor 620 of an electronic device 600 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0305] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform any of the processing methods of the electronic device described in the embodiments of this disclosure. For example, the method includes:
[0306] In response to entering any detection phase of a preset period, based on the timing of the detection phase within the preset period, a task to be processed in the detection phase is determined from the target tasks; wherein the target task is created within the preset period, and the preset period includes at least two detection phases; each detection phase is sequentially continuous; the correlation between terminating the task to be processed and the restart of the electronic device is positively correlated with the timing of the detection phases;
[0307] If an anomaly is determined to exist in the electronic device based on the task to be processed, the anomaly is recovered based on the recovery strategy corresponding to the detection phase.
[0308] This disclosure provides a computer program product comprising a computer program or executable instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer program or executable instructions from the computer-readable storage medium and executes the computer program or executable instructions, causing the computer device to perform any of the processing methods of the electronic device described in this disclosure.
[0309] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0310] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A processing method for an electronic device, characterized in that, include: In response to entering any detection phase of a preset period, based on the timing of the detection phase within the preset period, a task to be processed in the detection phase is determined from the target tasks; wherein the target task is created within the preset period, and the preset period includes at least two detection phases; each detection phase is sequentially continuous; the correlation between terminating the task to be processed and the restart of the electronic device is positively correlated with the timing of the detection phases; If an anomaly is determined to exist in the electronic device based on the task to be processed, the anomaly is recovered based on the recovery strategy corresponding to the detection phase.
2. The method according to claim 1, characterized in that, The step of determining the tasks to be processed in the detection phase based on the timing of the detection phase within the preset period includes: For each of the target tasks, determine the process associated with the target task; The processes associated with each of the target tasks are compared with the reference processes in the process set corresponding to the detection stage to obtain a first comparison result; wherein, each detection stage corresponds to a process set, and the degree of association between interrupting the reference processes in different process sets and the restart of the electronic device is different; If the first comparison result indicates that there is a target process that matches any reference process in the process set, the target task corresponding to the target process is determined as the task to be processed.
3. The method according to claim 2, characterized in that, The methods for determining that the electronic device is abnormal based on the task to be processed include: The communication duration of at least two target processes is determined from the call chain information during the execution of the task to be processed; wherein, the call chain information represents the link information of the communication between the at least two target processes based on the inter-process communication mechanism; If the duration of any of the communication sessions exceeds the duration threshold corresponding to the detection phase, it is determined that the electronic device has the anomaly; wherein each detection phase corresponds to a duration threshold.
4. The method according to claim 2, characterized in that, The method further includes: Identify the reference process that caused the electronic device to malfunction, and determine the correlation between an interruption operation on the reference process and a restart of the electronic device; Based on the correlation, the reference process is stored in the corresponding process set.
5. The method according to claim 1, characterized in that, The recovery strategy based on the detection phase is used to recover from the anomaly, including: Based on the invocation status of at least two target processes associated with the task to be processed, determine the cause of the abnormality that led to the abnormality in the electronic device; Based on the aforementioned cause of the anomaly, a process to be processed is determined from the at least two target processes; Based on the recovery strategy corresponding to the detection phase, the process to be processed is processed.
6. The method according to claim 5, characterized in that, The process to be processed based on the recovery strategy corresponding to the detection phase includes: If the abnormality exists in the first detection phase of the preset period, the pending process determined in the first detection phase is interrupted. The first detection stage is the first detection stage of the preset cycle.
7. The method according to claim 6, characterized in that, The process to be processed based on the recovery strategy corresponding to the detection phase includes: If the anomaly exists in the first time unit of the second detection phase of the preset period, the process information of the process to be processed determined by the first time unit is stored; wherein, the second detection phase is the detection phase following the first detection phase; If the abnormality exists in the second time unit of the second detection phase, the process to be processed determined by the second time unit is processed based on the second comparison result between the process information of the process to be processed determined by the second time unit and the process information stored in the first time unit. The second time unit is sequentially continuous with the first time unit.
8. The method according to claim 7, characterized in that, The second comparison result between the process information of the process to be processed determined by the second time unit and the process information stored in the first time unit, and the processing of the process to be processed determined by the second time unit, includes: If the second comparison result indicates that the process information of the second time unit matches the process information of the first time unit, the electronic device is restarted.
9. The method according to claim 7, characterized in that, The second comparison result between the process information of the process to be processed determined by the second time unit and the process information stored in the first time unit, and the processing of the process to be processed determined by the second time unit, includes: If the second comparison result indicates that the process information of the second time unit does not match the process information of the first time unit, the process information stored in the first time unit is cleared. If the abnormal duration reaches the first threshold, the pending process determined by the second time unit is interrupted; Wherein, the first threshold is greater than the duration threshold corresponding to the second detection stage.
10. The method according to any one of claims 1 to 9, characterized in that, In response to entering any detection phase of a preset period, based on the timing of the detection phase within the preset period, the task to be processed in the detection phase is determined from the target tasks, including: In response to entering the first detection phase of the preset period, if the duration of entering the first detection phase reaches a second threshold, the step of determining the task to be processed from the target task based on the first time interval is repeated until the second detection phase is entered from the first detection phase. In response to entering the second detection phase, the step of determining the task to be processed from the target task based on the second time interval is repeated until the next preset cycle is entered; The second time interval is greater than the first time interval.
11. An electronic device, characterized in that, include: The determination module is configured to, in response to entering any detection phase of a preset period, determine the pending task of the detection phase from the target tasks based on the timing of the detection phase within the preset period; wherein the target task is created within the preset period, and the preset period includes at least two detection phases; each detection phase is sequentially consecutive; the correlation between terminating the pending task and the restart of the electronic device is positively correlated with the timing of the detection phases; The recovery module is configured to recover from the anomaly based on the recovery strategy corresponding to the detection phase when it is determined that the electronic device has an anomaly based on the task to be processed.
12. The device according to claim 11, characterized in that, The determining module is specifically configured as follows: For each of the target tasks, determine the process associated with the target task; The processes associated with each of the target tasks are compared with the reference processes in the process set corresponding to the detection stage to obtain a first comparison result; wherein, each detection stage corresponds to a process set, and the degree of association between interrupting the reference processes in different process sets and the restart of the electronic device is different; If the first comparison result indicates that there is a target process that matches any reference process in the process set, the target task corresponding to the target process is determined as the task to be processed.
13. The device according to claim 11, characterized in that, The recovery module is specifically configured as follows: Based on the invocation status of at least two target processes associated with the task to be processed, determine the cause of the abnormality that led to the abnormality in the electronic device; Based on the aforementioned cause of the anomaly, a process to be processed is determined from the at least two target processes; Based on the recovery strategy corresponding to the detection phase, the process to be processed is processed.
14. An electronic device, characterized in that, include: processor; Memory used to store computer programs or instructions; The processor executes the computer program or instructions to implement the steps of the method according to any one of claims 1 to 10.
15. A non-transitory computer-readable storage medium storing a computer program or instructions, characterized in that, When the computer program or instructions in the storage medium are executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
16. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 10.
