Application exception processing method, electronic equipment and computer readable medium

By establishing an abnormal notification transmission channel between native applications and third-party applications on terminal electronic devices, the user data loss and interface recovery problems caused by unanticipated exit of the application are solved, and the application's independent recovery and interface recovery are realized, improving the user experience.

CN119917322APending Publication Date: 2025-05-02HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311439608.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-31
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

The applications installed on the terminal electronic device may exit unexpectedly during operation due to insufficient memory or program code failure, resulting in user data loss and inability to resume operation on its own, and the interface before the application is unanticipated exit cannot be restored.

Method used

By establishing an exception notification transmission channel between the native application and the third-party application on the electronic device, the native application can notify the third-party application system of an exception and back up the status and data before the exception notification, so that the application will restart and restore the interface before exiting after the application is unexpectedly exited.

Benefits of technology

It realizes that the application can resume operation on its own after unexpected exit, and restore the interface before the exit is displayed, bringing a more coherent user experience to the user and avoiding the loss of user data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917322A_ABST
    Figure CN119917322A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of terminals, in particular to an application exception processing method, electronic equipment and a computer readable medium. According to the method, a transmission channel is established between a native application running a shell program and a related third-party application, and the native application can inform the related third-party application of abnormity, errors and the like notified by a system based on the transmission channel. And the third-party application which exits abnormally can receive the restart instruction based on the transmission channel to recover operation, and the third-party application can recover the interface before the abnormal exit based on the timely backup state and data when the third-party application recovers operation. Therefore, for some third-party applications running in different systems, restarting can be triggered to recover running after abnormal exit, and the third-party applications can be informed of backup states and data in time to recover an interface before exit, so that more coherent use experience is brought to a user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of terminal technology, and in particular to an application exception handling method, an electronic device and a computer-readable medium. Background Art

[0002] The applications (APP) installed on the terminal electronic device (hereinafter referred to as the terminal or electronic device) will inevitably produce some unexpected behaviors during operation, such as application freezing or program crash due to insufficient memory or application program code failure. The default processing method of the terminal operating system (OS) for these unexpected behaviors is to directly terminate the application process, at which time the application will unexpectedly exit. If user data is generated during the operation of the application, directly terminating the application process may cause the loss of user data.

[0003] Therefore, it is necessary to provide an application exception handling solution that can resume the application after the application unexpectedly exits and restore the user data generated before the unexpected exit, so that the terminal can also restore the interface of the application before the unexpected exit. Summary of the invention

[0004] The present application provides an application exception handling method, an electronic device and a computer-readable medium. The solution can trigger restart and recovery of some third-party applications running on a different system after an unexpected exit, and can enable some third-party applications to back up status and data in time to restore the interface before exit, thereby providing users with a more consistent user experience.

[0005] In a first aspect, the present application provides an application exception handling method, which is applied to an electronic device, on which a first operating system, a first application developed based on the first operating system, and a second application developed based on a second operating system are installed; and the method includes: displaying a first interface of the second application, wherein a shell program of the second application runs in a first process of the first application; the second application exits abnormally; and restoring display of the first interface of the second application.

[0006] That is, the electronic device is installed with a type of operating system, such as the above-mentioned first operating system. When the electronic device runs a third-party application (such as the above-mentioned second application) developed by a different system (such as the above-mentioned second operating system), the shell program of the third-party application can run in the process of a local application (hereinafter referred to as a native application, such as the above-mentioned first application) developed based on the operating system installed on the electronic device. When the above-mentioned third-party application exits unexpectedly (that is, the above-mentioned abnormal exit), the electronic device can restore the display of the interface displayed by the third-party application before exiting based on the application recovery method provided by the above-mentioned first aspect.

[0007] It is understandable that when a third-party application is running on other operating systems, it will usually run in a specific execution environment provided by a container or virtual machine corresponding to the operating system. The shell program of the third-party application can usually run in the process of a native application developed under the operating system to facilitate the calling of system resources to display the application interface and interact with the user. When the process of the native application or the shell program of the third-party application may be at risk of abnormal exit due to insufficient system memory or other related failures, the native application often cannot notify the third-party application of the abnormality in a timely manner, which will cause the third-party application to abnormally exit and be unable to restart and restore the display of the interface before the exit. In the application exception handling method provided in the first aspect of the present application, the electronic device can restart and restore the display of the interface before the third-party application abnormally exits, that is, the above-mentioned first interface, after the third-party application abnormally exits.

[0008] In a possible implementation of the first aspect above, restoring the display of the first interface of the second application includes: the second application receives an exception notification at a first moment, saving a first state and first user data corresponding to the display content of the first interface, wherein the first moment is earlier than a second moment when the second application exits abnormally, and the first state includes at least a page stack corresponding to the display content of the first interface and data saved in a state data saving interface; the second application exits abnormally at the second moment, and generates a first interface based on the first state and the first user data.

[0009] Specifically, the electronic device used in the present application can restore the display of the interface before the third-party application unexpectedly exits, by notifying the third-party application system that an abnormality has occurred at a certain moment before the abnormal exit (for example, the first moment mentioned above), that is, the second application receives the abnormal notification. At this time, the third-party application can promptly save the status and data related to the interface displayed at that moment (for example, the first interface), such as the first state and the first user data mentioned above, including the page stack of the display content of the relevant interface and the data saved in the status data storage interface. In this way, after the third-party application exits abnormally, it can be restarted and restored to display the interface before the abnormal exit based on the saved status and data.

[0010] In a possible implementation of the first aspect above, the first application is a native application, the second application includes a container application or a virtual machine application, the electronic device includes a first service for managing the container or the virtual machine, and the second application receives an exception notification at a first moment, including: the second application receives a first exception notification sent by the first service, wherein the first exception notification is generated by the first service in response to a second exception notification sent by the first application.

[0011] In some examples of the present application, the first application is a native application, that is, a local application developed under the operating system installed on the electronic device, also known as a shell application, which is used to run the shell program (shell) corresponding to each third-party application package to provide a user interface (UI) to the user. The second application is a container application or a virtual machine application developed based on virtualization technology under other operating systems. Among them, according to different virtualization technologies applicable to different operating systems, the container applications include Linux TM Applications, Harmony TM Apps and Android TM Applications, etc. Virtual machine applications include Windows TM Apps, Mac TM Correspondingly, the operating system installed in the electronic device may also include a virtualization management service capable of managing containers or virtual machines, such as a container engine for managing containers, or a virtual machine monitor for managing virtual machines, while providing a specific execution environment for the above-mentioned second application through a container or a virtual machine.

[0012] In this way, the electronic device can use the above-mentioned first service to interact with the native application to establish a transmission channel for abnormal notifications, for example, to notify the third-party application of the abnormal system notification received by the native application, thereby triggering the third-party application to save status and data.

[0013] It is understandable that the process of the second application receiving the first abnormal notification and the first service receiving and responding to the second abnormal notification sent by the first application can be performed simultaneously. In this way, when the native application receives the abnormal situation notified by the system, it can notify the second application through the first service, so that the second application can save the state and data in time.

[0014] In a possible implementation of the first aspect above, the electronic device includes a second service, and the method includes: detecting a fault related to the operation of the second application through the second service, and sending a third exception notification to the first application; in response to the third exception notification, the first application sends a second exception notification to the first service.

[0015] For example, the second service may be a system service for detecting faults related to the operation of third-party applications. The system service may include an anomaly detection component for obtaining relevant system logs or application logs during the operation of the operating system installed on the electronic device to determine whether a fault related to the operation of the third-party application occurs, and then determine whether anomalies and errors that may cause the third-party application to exit unexpectedly occur. In this way, the electronic device can use the second service to notify the first application, such as a native application, of the detected anomalies and errors. Furthermore, the first application may continue to notify the first service, such as a virtualization management service, of the anomalies and errors, which are not limited here.

[0016] In a possible implementation of the first aspect above, the type of fault related to the running of the second application includes any one of the following: JS_CRASH; CPP_CRASH; APP_FREEZE; KILL.

[0017] Among them, JS_CRASH refers to the abnormal termination or crash of JavaScript code due to code errors, insufficient memory, etc.; CPP_CRASH refers to the termination or crash of C++ program due to code errors, memory leaks, etc.; APP_FREEZE refers to the freezing of application due to insufficient resources, code errors or other problems, usually manifested as unresponsive or stopped application; KILL usually refers to the operating system or application being forced to close or terminate due to insufficient system resources, application errors, etc.

[0018] In a possible implementation of the first aspect above, the second application exits abnormally, including: a second process of the second application running in a first container or a first virtual machine is abnormally terminated, wherein the first container is used to provide an execution environment for the container application in the first operating system, and the first virtual machine is used to provide an execution environment for the virtual machine application in the first operating system; and the first process of the first application is abnormally terminated.

[0019] That is, the unexpected exit of the third-party application can be reflected in the abnormal termination of the process (such as the first process) of the native application (such as the first application) run by the shell program of the third-party application, and the abnormal termination of the process (such as the second process) run by the third-party application in the corresponding container. No limitation is made here.

[0020] In a possible implementation of the first aspect above, restoring and displaying the first interface of the second application includes: the first service creates a third process in the first container in response to a restart notification sent by the first application, and sends a restart instruction to the second application; the second application responds to the restart instruction, restarts running in the third process, generates, and resumes displaying the first interface.

[0021] In a possible implementation of the first aspect above, restoring the display of the first interface of the second application includes: in response to a user operation of restarting the second application, the second application starts running and restoring the display of the first interface.

[0022] It is understandable that the second application, such as a third-party application developed by a different system, can restart and run in the process (such as the third process) created by the first service (such as the virtualization management service) based on the restart instruction sent by the first service (such as the virtualization management service) after abnormal exit. In addition, after the second application is restarted, it can restore the interface before the abnormal exit, such as the first interface.

[0023] In a possible implementation of the first aspect above, the exception type corresponding to the notification of the first exception notification includes any one of the following: an exception caused by insufficient memory; an exception caused by at least one failure of JS_CRASH, CPP_CRASH, APP_FREEZE, and KILL; an exception caused by the user's instruction to clean up memory or terminate application processes in batches.

[0024] It is understandable that there may be multiple reasons for the unexpected exit of the third-party application, so the exception type of the notification corresponding to the first exception notification may also include any of the above multiple items. In other embodiments, the exception type of the notification corresponding to the first exception notification may also include other types different from the above items, which are not limited here.

[0025] In a possible implementation of the first aspect above, the electronic device also includes a third application developed based on a third operating system, and the third operating system is of a different type from the second operating system; and the shell program of the third application runs in a fourth process of a fourth application, and the fourth application is a native application developed based on the first operating system.

[0026] That is, third-party applications developed based on different operating systems can have their respective shell programs run in the processes of different native applications. TM Applications and Windows TM The shell programs of applications can run in the processes of different native applications. Correspondingly, the shell programs of third-party applications developed based on the same operating system can run in the process of the same native application. TM Application A and Linux TM The shell program of application B can run in the process of the same native application.

[0027] In a possible implementation of the first aspect, the first operating system and the second operating system are of different types, and,

[0028] The types of the first operating system and the second operating system include any of the following: OpenHarmony TM ;HarmonyOS TM ;Linux TM ;Android TM ; Windows TM ; Mac TM .

[0029] In a second aspect, the present application provides an electronic device, comprising: one or more processors; one or more memories; one or more memories storing one or more programs, and when one or more programs are executed by one or more processors, the electronic device executes the application exception handling method provided by the above-mentioned first aspect and various possible implementations of the first aspect.

[0030] In a third aspect, the present application provides a computer-readable medium having instructions stored thereon, which, when executed on a computer, causes the computer to execute the application exception handling method provided by the first aspect and various possible implementations of the first aspect.

[0031] In a fourth aspect, an embodiment of the present application provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the application exception handling method provided by the above-mentioned first aspect and various possible implementations of the first aspect.

[0032] The beneficial effects of the second to fourth aspects mentioned above can be referred to the relevant descriptions in the first aspect mentioned above and various possible implementations of the first aspect, and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 The figure shows a schematic diagram of an application scenario of an application exception handling method.

[0034] Figure 2 The figure shows a schematic diagram of a system structure capable of providing an application recovery function provided in an embodiment of the present application.

[0035] Figure 3 The figure shows a schematic diagram of the system structure based on which an application exception handling method provided in an embodiment of the present application is implemented.

[0036] Figure 4 The figure is a schematic diagram of the relationship between a native application provided in an embodiment of the present application and a third-party application developed based on different operating systems.

[0037] Figure 5 The figure shows an interactive flow diagram of an application exception handling method provided in Example 1 of the present application.

[0038] Figure 6a The figure shows a schematic diagram of the interface when a third-party application is unresponsive and resumes operation, provided in Example 1 of the present application.

[0039] Figure 6b The figure shows a schematic diagram of the interface when a third-party application is unresponsive and resumes operation, provided in Example 1 of the present application.

[0040] Figure 6c The figure shows a schematic diagram of an interface when a third-party application unexpectedly exits and resumes operation, as provided in Example 1 of the present application.

[0041] Figure 7 The figure is a schematic diagram of the implementation process of an application exception handling method provided in Example 1 of the present application.

[0042] Figure 8 The figure shows an interactive flow diagram of an application exception handling method provided in Example 2 of the present application.

[0043] Fig. 9 Shown is a schematic structural diagram of an electronic device provided in an embodiment of the present application.

[0044] Fig.10 Shown is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0046] It should also be stated that the steps in the methods and processes in the embodiments of the present application are numbered for ease of reference, rather than to limit the order of precedence. If there is an order between the steps, the text description shall prevail.

[0047] As mentioned above, when an application running on a terminal unexpectedly exits, user data may be lost, and the application cannot be restored by itself. The terminal is often unable to restore the interface before the application unexpectedly exits.

[0048] Figure 1 A schematic diagram of an application scenario of an application exception handling method is shown.

[0049] refer to Figure 1 As shown, this application scenario takes the mobile phone 100 and the mall application as an example, including an example of interface changes corresponding to an unexpected exit of the application during the running of the mall application by the mobile phone 100.

[0050] When the mobile phone 100 is running the shopping mall application, it can respond to the user's operation of selecting the "shopping cart" option and display Figure 1 The shopping cart checkout interface 101 is shown. In an exemplary scenario, a user can Figure 1 After clicking the checkbox control 011 to select "Product X01" and clicking the checkbox control 012 to select "Product X02" on the shopping cart settlement interface 101 shown, clicking the settlement control 013 triggers the mobile phone 100 to display the payment interface for payment. At this time, if the operating system of the mobile phone 100 runs the above-mentioned mall application abnormally, the operating system of the mobile phone 100 may terminate the application process corresponding to the mall application, thereby causing the mall application to exit unexpectedly. At this time, the mobile phone 100 can return to displaying the desktop or other interfaces of normally running applications.

[0051] If the user wants to continue to pay, he can click the application icon corresponding to the above-mentioned mall application on the desktop of the mobile phone 100. After the mobile phone 100 restarts and runs the mall application, the corresponding default interface can be displayed. Figure 1 The home page interface 102 shown. The user can select the "shopping cart" option 021 on the home page interface 102 to make the mobile phone 100 redisplay the above-mentioned shopping cart settlement interface 101. Then, the user can click the settlement control 013 on the interface 101 to trigger the mobile phone 100 to display the payment interface.

[0052] In the above Figure 1 In the application scenario shown, if a shopping mall application running on an electronic device such as mobile phone 100 exits unexpectedly, the electronic device such as mobile phone 100 may not be able to automatically resume the unexpectedly exited application. Moreover, after the mobile phone 100 restarts the unexpectedly exited application in response to the user's operation, it cannot restore the interface before the application exits. This will cause the user's coherent use experience to deteriorate.

[0053] In response to the above problems, Figure 2 A schematic diagram of a system structure capable of providing an application recovery function is shown.

[0054] like Figure 2 As shown, the system may include OpenHarmony TM System, HarmonyOS TM etc., and the applications running on the system are developed under different operating systems, such as Linux TM System, Windows TM System or Mac TM System development applications, etc.

[0055] Continue to refer Figure 2The framework of the system can provide a system service, such as Foundation, for application recovery function calls. The system service can include an exception detection component. The exception detection component can detect abnormal fault types including JS_CRASH, CPP_CRASH, APP_FREEZE, and KILL, which may cause unexpected exits and errors.

[0056] Among them, JS_CRASH refers to JavaScript crash. It usually occurs in a web browser, and the JavaScript code terminates abnormally or crashes due to code errors, insufficient memory, etc.

[0057] CPP_CRASH refers to a C++ crash. It usually occurs in a C++ program, which causes the C++ program to terminate abnormally or crash due to code errors, memory leaks, etc.

[0058] APP_FREEZE means that the application is frozen. It usually occurs in the operating system or application, which may be caused by insufficient resources, code errors, or other problems. APP_FREEZE failures cause exceptions such as the application being unresponsive or stopping responding.

[0059] KILL usually refers to the forced closure or termination of the operating system or application due to insufficient system resources, application errors, etc. KILL failures cause exceptions such as process exit or process failure.

[0060] These exceptions and errors may be caused by insufficient memory or program code exceptions, etc. The above exception detection component can also detect abnormal situations such as user memory cleaning or batch management of application running status, which may cause some third-party applications to exit unexpectedly, and other abnormal types are not limited here.

[0061] The above anomaly detection component can be called after the application initialization phase, and can be executed Figure 2 The "① Exception Notification" process shown in the figure notifies the application of unhandled exceptions and errors in the system. The exception detection component can also perform Figure 2 The "② State Saving" process shown notifies the running application to save temporary data during the running process. The temporary data may include the real-time running state of the application and user data generated during the running process.

[0062] refer to Figure 2As shown, the application installed in the system may be integrated with a backup and recovery component, and the backup and recovery component may timely back up the temporary data in response to the abnormality notification or state preservation notification sent by the abnormality detection component. It can be understood that the user data included in the temporary data may include business data, UI data, files, system context, and network or location data generated during the operation of the application, and the state included in the temporary data may include data saved in the page stack and the state data preservation interface, which is not limited here.

[0063] Continue to refer Figure 2 As shown, the above anomaly detection component can also perform Figure 2 The "③ state recovery" process shown in the figure notifies the running application to restore the interface before the unexpected exit. In this way, after an unexpected exit occurs, the application running on the electronic device such as the mobile phone 100 can automatically resume the operation of the unexpectedly exited application based on the application recovery function provided by the above system, and can restore the display of the interface of the application before the unexpected exit, giving the user a more coherent user experience.

[0064] but, Figure 1 The operating system installed on the mobile phone 100 in the application scenario shown may be different from the operating system based on which the above-mentioned mall application is developed. Figure 2 OpenHarmony shown TM System, HarmonyOS TM etc. (recorded as the first system), while the mall application is based on Linux TM System, Windows TM System or Mac TM system (referred to as the second system). At this time, Linux TM Apps or Windows TM Apps and other third-party apps are compatible with OpenHarmony TM In the system, the native application running the corresponding shell program may not be able to pass the exceptions and errors detected by the system to the third-party application, resulting in the third-party application still being unable to resume operation after an unexpected exit. Figure 2 The terminal of the system shown still cannot restore the interface of some third-party applications before the unexpected exit. Among them, native applications, also known as native applications or shell applications, refer to local applications developed for the development interface and supported development language of a specific operating system, which are used to run the corresponding encapsulated shell program (shell) of each third-party application to provide a user interface (UI) to the user.

[0065] In order to solve the above problems, the present application provides an application exception handling method. Specifically, the method establishes a transmission channel between the native application running the shell program and the related third-party application, and the native application can notify the related third-party application of the exceptions and errors notified by the system based on the transmission channel. Correspondingly, the third-party application that unexpectedly exits can also resume operation based on the received restart instruction, and the third-party application that integrates or calls the backup and recovery function can also restore the interface of the third-party application before exiting based on the backed-up status and data of the system exceptions and errors notified by the above transmission channel when resuming operation. In this way, for some third-party applications, even if they are running in different operating systems, they can trigger a restart and resume operation after an unexpected exit, and some third-party applications can also back up the status and data in time and then restore the interface before exiting, giving users a more coherent user experience.

[0066] Among them, the third-party application in the embodiment of the present application refers to an application developed based on the second system, and the second system is an operating system different from the operating system (i.e., the first system) running the third-party application. In view of the different kernel architectures supported by different second systems, the third-party application may also include different types of applications. For example, the third-party application may include a container application developed based on container virtualization (docker) technology, such as a container application that supports isomorphic Linux. TM Kernel Linux TM System, OpenHarmony TM System and Android TM (Android TM ) system to develop Linux TM Applications, Harmony TM Apps and Android TM For example, the third-party applications may also include virtual machine applications developed based on virtual machine technology, such as Windows that supports heterogeneous system kernels. TM System, Mac TM Windows developed in the system TM Apps, Mac TM Applications, etc., are not limited here.

[0067] In an embodiment of the present application, the above-mentioned transmission channel can be implemented by a virtualization management service provided by an operating system carried by an electronic device. For example, when a native application receives a system notification corresponding to an exception or error of a related third-party application, it can notify the related third-party application through the above-mentioned virtualization management service. The virtualization management service can also restart the third-party application that exited unexpectedly or send a restart notification to the related third-party application in the process of managing the process running in the container or virtual machine in which the related third-party application runs, so as to instruct the related third-party application to resume operation and resume display of the interface before exiting, etc. In some embodiments, the above-mentioned virtualization management service can be set in the application framework layer or system service layer of the operating system, etc. For details, please refer to the relevant description below, which will not be repeated here. In other embodiments, the above-mentioned virtualization management service can also be pre-integrated in the native application as a functional module for managing third-party applications, which is not limited here.

[0068] It is understandable that, as a tool for managing containers or virtual machines, the virtualization management service can be embodied in different tool forms in different operating systems. TM System, OpenHarmony TM System and Android TM (Android) TM In systems such as Docker, the above virtualization management service can be embodied as a container engine (Docker engine), such as Docker Swarm, Rancher, Mesos, etc. For another example, in Windows TM System, Mac TM In systems such as the above, the virtualization management service can be embodied as a virtual machine monitor (hypervisor), which is not limited here.

[0069] In other embodiments, the above transmission channel can also be established through the support of other services or related functional module SDKs, etc., which is not limited here.

[0070] It can be understood that the above-mentioned third-party applications timely back up the status and data based on the integrated or called backup and recovery function, including the application's page stack and the data saved in the status data preservation interface; it may also include status information of different applications running in the foreground or background, network connection status, and whether download tasks are being executed, and may also include the tasks currently executed by the application, the currently opened file path, the progress of the currently executed tasks, etc., without limitation here.

[0071] It can be understood that the application exception handling method provided in the embodiment of the present application is applicable to electronic devices including but not limited to mobile phones, tablet computers, desktops, laptops, handheld computers, netbooks, and augmented reality (AR) / virtual reality (VR) devices, smart TVs, smart watches and other wearable devices, car equipment, portable game consoles, portable music players, reader devices, and other electronic devices with one or more processors and / or capable of accessing the network.

[0072] Figure 3 According to an embodiment of the present application, a schematic diagram of a system structure based on which an application exception handling method is implemented is shown.

[0073] like Figure 3 As shown, the system 300 may adopt a layered architecture, which may include an application layer 310 , an application framework layer 320 , a system service layer 330 , and a kernel layer 340 .

[0074] The application layer 310 may be installed with a series of applications, and the application bundles of each application may be executed in the application layer 310 to support the operation of related applications. The above applications may include, for example, camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc., without limitation.

[0075] In the embodiment of the present application, the applications installed in the application layer 310 may include native applications 311 , third-party applications 312 , and other applications 313 .

[0076] The specific operating system may be Figure 3 The system 300 shown has different types of other operating systems (referred to as heterogeneous systems), such as Linux TM System or Windows TM System, etc. Usually, the native application 311 can be run on a host, so the native application 311 is also a host APP.

[0077] The third-party application 312 can be an application developed based on a different system and capable of providing the required functions to the user, and needs to run in a specific execution environment provided by a container or a virtual machine. The container enables the process of the third-party application 312 to run in a relatively independent and isolated environment, that is, the above-mentioned specific execution environment, which can include an independent file system, namespace, resource view, etc., or can independently run a sub-operating system, etc., which can ensure that the program code of the third-party application 312 is smoothly executed in the environment. The above-mentioned specific execution environment is conducive to enhancing the portability and security of the third-party application 312 and improving the utilization rate of the system 300 resources. In addition, the shell program corresponding to the encapsulation of the third-party application 312 can run in the process of the native application 311, and send and display the UI interface provided by the corresponding third-party application 312, so that the native application 311 can use the use rights of the system resources to achieve a better user interaction experience. Among them, the process of the third-party application 312 can interact with the process of the native application 311 through interprocess communication (IPC), call the graphics service of the application framework layer 320, etc., and generate the corresponding UI interface.

[0078] In some other embodiments, the applications installed in the application layer 310 may also include virtual machine applications, such as Windows TM Apps, Mac, etc. TM Similarly, the virtual machine application may be an application running in a specific execution environment provided by a virtual machine (VM), and the shell program encapsulated by the virtual machine application may also run in the native application 311 .

[0079] It can be understood that the shell programs corresponding to different third-party applications 312 developed based on the same operating system can run in the process of the same native application 311, and the shell programs of third-party applications 312 developed based on different operating systems can run in the processes of different native applications 311. It can be understood that the same shell program can provide multiple interfaces for each application, including A1...An, B1...Bn, etc., corresponding to third-party application A, third-party application B, etc.

[0080] As an example, refer to Figure 4 As shown, the application layer 310 of the system 300 may include multiple native applications 311, such as native application 311a, native application 311b, etc. In the embodiment of the present application, if the system 300 is OpenHarmony TMAs an example, the native application 311a may run a shell program adapted to a third-party application developed by a type of system, and the shell program may be used to support one or more third-party applications developed based on the same system, such as the container application Linux TM Application A and Linux TM Application B.

[0081] Similarly, the native application 311b may run a shell program adapted to a third-party application developed by another type of system, and the shell program may be used to support one or more third-party applications developed based on the same system, such as a virtual machine application Windows TM Application A and Windows TM Application B, etc., is not limited here.

[0082] In some embodiments, if the above Figure 3 The system 300 shown is a Linux TM system, the third-party application 312 may also be based on Windows TM Applications developed by the system may be based on OpenHarmony TM System development applications, etc., the shell programs of third-party applications 312 can run on Linux TM In the native application 311 of the system. In other embodiments, if the above Figure 3 The system 300 shown is a Windows TM system, the third-party application 312 may also be based on Linux TM Applications developed by the system may be based on OpenHarmony TM The shell programs of third-party applications 312 can run on Windows TM The system's native application 311 is not limited here.

[0083] Other applications 313 can be based on Figure 3 The applications developed by the system 300 shown include system applications and third-party applications, etc., which are not limited here.

[0084] Continue to refer Figure 3 As shown, the native application 311 and other applications may be integrated with a backup and recovery component that can receive anomalies and errors detected by the system, and timely back up and restore temporary data generated during the operation of the native application 311 and other applications 313.

[0085] In some embodiments, the third-party application 312 may also be integrated with a backup and recovery component to receive anomalies and errors detected by the system and to back up or restore temporary data generated during the operation of the third-party application 312 .

[0086] Continue to refer Figure 3 As shown, the application framework layer 320 can provide a framework and some system services developed based on the corresponding framework for the application layer 310. Among them, the framework can be an open source framework or a closed source framework, and the framework service is, for example, the system service such as the above-mentioned Foundation for realizing the intercommunication (startup, call, migration) functions within the system and between systems, which is not limited here. The application framework layer 320 can also include the application programming interface (API) corresponding to each system service.

[0087] The system service layer 330 is the core of the system 300. The system service layer 330 provides services to the applications (APP) and software development kits (SDK) in the application layer 310 through the application framework layer 320. In some embodiments of the present application, the above-mentioned backup and recovery component can provide the service functions of backing up and restoring status and data to the above-mentioned third-party applications 312 in the form of SDK. The SDK can run in the system service layer 330 and provide the third-party application 312 with a calling interface for corresponding service functions. In some other embodiments of the present application, the third-party application 312 can also integrate the backup and recovery component SDK into the application package. It is understandable that when the third-party application 312 integrates the above-mentioned backup and recovery component SDK or calls the service interface of the above-mentioned backup and recovery component SDK, it can interact with the native application 311 through the virtualization management service to implement the application exception handling method provided by the present application. For details, please refer to the relevant description below, which will not be repeated here.

[0088] The framework services provided by the application framework layer 320 may include virtualized graphics services 321, virtualized management services 322, and application management services 323. The system service layer 330 may provide system services 331, etc., through the framework provided by the application framework layer 320. An anomaly detection component may be configured in the system service 331 to perform an anomaly detection function.

[0089] A virtualized graphics service 321, such as a container graphics service or a virtual machine graphics service, can respond to the call of the process of the above-mentioned third-party application 312, and provide a calling interface of interface graphics resources, a calling interface of graphics drawing and graphics rendering functions, etc. to each third-party application 312 related to the shell program running in the process of the native application 311, without any limitation here.

[0090] Virtualization management service 322 can be used to manage containers or virtual machines in the system that support various operating systems, including Linux TM Containers, WindowsTM In some embodiments, the virtualization management service 322 may include one or more virtual machines, such as Linux TM Virtualization Management Service, Windows TM One or more of the virtual machine management services are used to manage the life cycle of the third-party application 312 and to build and manage the container resources required by the third-party application 312.

[0091] Among them, the management of containers supporting various operating systems by the virtualization management service 322 may include managing one or more third-party applications 312 running in the corresponding container or virtual machine, such as recording and maintaining the application package name, identification information, start-up, stop-operation, running status, and corresponding resource data called during the operation of each third-party application 312. It can be understood that third-party applications 312 developed based on the same operating system can run in the same container, and each third-party application 312 can run in its own process sandbox to achieve data isolation.

[0092] In other embodiments, the management function of the third-party application 312 running in the container provided by the virtualization management service 322 can also be implemented by integrating the corresponding functional modules in the native application 311. Correspondingly, when the native application 311 obtains the exceptions and errors notified by the system service 331, it can send an exception notification to the relevant third-party application 312 and receive the backup completion notification fed back by the relevant third-party application 312 through the integrated functional module with the above-mentioned management function for the third-party application 312. No limitation is made here.

[0093] The application management service 323 is used to manage all applications installed in the application layer 310, including the native application 311 and other applications 313, and may also include the third-party application 312. The management of each application by the application management service 323 may include creating some application processes, starting and running applications, and may also include ending some application processes, stopping and running applications, etc., which will not be described in detail here.

[0094] The kernel layer 340 is a layer between hardware and software. In the embodiment of the present application, the kernel layer 340 of the system 300 may include: a kernel subsystem and a driver subsystem. Among them, the kernel subsystem may adopt a multi-kernel design, so the kernel subsystem supports the selection of a suitable OS kernel for different resource-constrained devices.

[0095] The kernel abstract layer (KAL) on the kernel subsystem shields the differences between multiple kernels and provides basic kernel capabilities to the upper layer, including process / thread management, memory management, file system, network management, and peripheral management.

[0096] The driver framework provided by the driver subsystem is the basis for the hardware ecosystem of the system 300 to be open, and can provide unified peripheral access capabilities and driver development and management frameworks. In some embodiments, the driver subsystem may include device drivers such as display drivers, camera drivers, and audio drivers, which are used to drive the corresponding devices to work and provide corresponding hardware capabilities.

[0097] It is understandable that the above Figure 3 The system 300 shown may be the first system running on the electronic device. For example, the system 300 may be the OpenHarmony TM System, HarmonyOS TM Or other operating systems with similar structures or capable of executing the application exception handling method provided by this application are not limited here.

[0098] It can be understood that the scenario to which the application exception handling method provided in the present application is applicable, that is, the scenario in which data / state is saved and restored before and after an application in a container (or virtual machine) of another system unexpectedly exits in an operating system, may include but is not limited to the following scenarios:

[0099] OpenHarmony TM Linux running on the system TM Containers, Android TM Container or Windows TM Application recovery within a virtual machine;

[0100] Windows TM Linux running on the system TM Containers, Android TM Container or Windows TM Application recovery within a virtual machine;

[0101] Linux TM Android running on the system TM Container or Windows TM Application recovery within a virtual machine;

[0102] Mac TM Linux is running on the system TM Container or Android TM Application recovery within the container.

[0103] Based on the above Figure 1 The application scenarios shown and the above Figure 3 The system structure diagram is shown, and the specific implementation process of the application exception handling solution provided by the present application is described in detail below in combination with specific embodiments and related drawings.

[0104] Example 1

[0105] In the embodiment of the present application, the application package of the third-party application 312 developed based on a different system may be integrated with a backup and recovery component SDK, or the relevant interface provided by the system of the electronic device may be called to call a component with backup and recovery capabilities. The third-party application 312 may register application information with the virtualization management service based on the integrated backup and recovery component SDK, and may automatically resume operation and restore the interface before the exit after an unexpected exit if the application recovery function is enabled.

[0106] Specifically, Figure 5 According to an embodiment of the present application, a schematic diagram of an interaction process of an application exception handling method is shown.

[0107] Understandably, Figure 5 The interaction process shown may involve the interaction between the process of the native application 311, the virtualization management service 322, the system service 331, and the process of the third-party application 312. In some embodiments, the operating system (such as the above Figure 3 The system 300 shown may be OpenHarmony TM system, third-party applications 312 may include third-party applications, such as Linux TM applications, etc.; it can also include virtual machine applications, such as Windows TM In other embodiments, the operating system installed in the terminal may also be Linux TM System or Mac TM system, third-party applications 312 can be Windows TM Applications, etc., are not limited here.

[0108] Among them, one or more shell programs of third-party applications 312 developed based on the same system can run in the process of the native application 311. In order to distinguish the third-party application that is not integrated with the backup and recovery component SDK in the following description, in the embodiment of the present application, the third-party application 312 that is integrated with the backup and recovery component SDK can be described as a third-party application 312A.

[0109] Specifically, Figure 5 As shown, the interaction process may include the following steps:

[0110] 501 : The native application 311 and the third-party application 312A enable the application recovery function to the system service 311 .

[0111] For example, referring to the above Figure 3In the structure shown, the native application 311 can register application information and component related information with the system service based on the configured backup and recovery component when it is initialized and run, so as to enable the application recovery function implemented based on the backup and recovery component. In this process, the native application 311 can also register an anomaly detection service with the system service 331, for example, by registering a listener and other methods to achieve registration.

[0112] The third-party application 312A running in the corresponding container or virtual machine can also register application information and component-related information with the virtualization management service 322 based on the configured backup and recovery component SDK during initialization, so as to enable the application recovery function implemented based on the backup and recovery component.

[0113] It can be understood that the application recovery function enabled by the backup recovery component can support the above-mentioned native application 311 and third-party application 312A to automatically resume operation and restore the interface before exiting after unexpected exit. For details, please refer to the description of the relevant steps below, which will not be repeated here.

[0114] 502: System service 331 performs anomaly detection.

[0115] For example, referring to the above Figure 3 In the structure shown, the system service 331 can detect exceptions and errors caused by factors such as insufficient memory or program code failures during the operation of related applications based on the exception detection component, wherein the above exceptions and errors may be caused by factors such as insufficient memory or program code failures of related applications during the system operation of related applications. The system service 331 can also detect exceptions such as abnormal situations that may cause the unexpected exit of the third-party application 312A due to the user's memory cleaning or batch management of application running status based on the exception detection component, which are not limited here.

[0116] It can be understood that the process of abnormality detection by the system service 331 can be performed based on the application information registered when the native application 311 and the third-party application 312A enable the application recovery function. For example, the system service 331 can obtain relevant system logs or application logs based on the application information of one or more applications in the native application 311 and the third-party application 312A to determine whether an abnormality and error occur. This will not be elaborated here.

[0117] In addition, the above-mentioned user operations of memory cleaning or batch management of application running status may be, for example, an operation in which the user clicks on the cleaning control on the memory cleaning notification or an operation in which the user clicks on the cleaning control on the storage management interface opened by the "Settings-Storage" option, etc., and are not limited here.

[0118] 503 : The system service 331 sends an exception notification to the native application 311 .

[0119] Exemplarily, when the system service 311 detects that one or more of the native applications 311 and the third-party applications 312A have anomalies and errors during operation, or that the user performs memory cleaning or batch management of application running status operations, etc., which may cause the third-party application 312A to exit unexpectedly, an abnormal situation, etc., an abnormal notification may be sent to the relevant native application 311. The abnormal notification may carry application information of the application where the abnormality occurs, such as application identifiers (AIDs) of the native application 311 and / or the third-party application 312A, etc., so that the native application 311 can identify or determine the application where the abnormality occurs.

[0120] It can be understood that the shell program running in the process of the native application 311 can provide an interface for one or more third-party applications 312A developed based on the same system. Therefore, the native application 311 can determine the third-party application 312A where the exception occurs and notify the virtualization management service 322 based on the running shell program and the application information carried by the received exception notification, so that the virtualization management service 322 sends the relevant exception notification to the relevant third-party application 312A.

[0121] 504: Native application 311 backs up state and data.

[0122] Exemplarily, when the native application 311 determines that the received exception notification corresponds to an indication of its own abnormal operation, it can back up the state and data based on the backup recovery component. In this way, the native application 311 can back up temporary data in time to avoid the loss of relevant state and user data when the native application 311 exits unexpectedly due to an exception. Among them, the state backed up by the native application 311 may include the page stack of the application and the data saved in the state data storage interface; it may also include status information such as the state of different applications running in the foreground or background, the network connection status, and whether the download task is being executed. It may also include the task currently executed by the application, the currently opened file path, the progress of the currently executed task, etc., without limitation here. The above-mentioned backed-up state and data can restore the relevant page content before exiting when the native application 311 is restarted after the unexpected exit, so that the interface before exiting can be restored.

[0123] 505 : The native application 311 sends an exception notification to the third-party application 312A through the virtualization management service 322 .

[0124] Exemplarily, when the native application 311 determines that the application indicated by the received exception notification corresponds to a third-party application 312A, the native application 311 can send an exception notification to the virtualization management service 322. Furthermore, the virtualization management service 322 can further send an exception notification to the relevant third-party application 312A based on the application information carried in the exception notification.

[0125] It is understood that the execution process of the above steps 502 to 504 and the execution process of the following steps 506 to 508 can be synchronized, or the above steps 502 to 504 and the following steps 506 to 508 can be completed before the process of the relevant application is terminated, and there is no limitation here. In this way, it can be ensured that the native application 311 and the third-party application 312A with the application recovery function enabled can complete the state and data backup process before unexpected exit.

[0126] 506: The virtualization management service 322 records relevant third-party application information.

[0127] Exemplarily, the virtualization management service 322 may record the application information such as the application identifier of the third-party application corresponding to the abnormal notification indicating the abnormality, as a basis for identifying the subsequent restart of the relevant application. In addition, the relevant third-party application information recorded by the virtualization management service 322 may also include the recorded status and data of the relevant third-party application. The status may also include the status information of multiple third-party applications running in the corresponding container or virtual machine, the network connection status, and whether the download task is being executed. The recorded data may include resource data related to the page content and some user data generated during the interaction with the user, etc., which are not limited here.

[0128] It can be understood that the relevant third-party application information recorded by the virtualization management service 322 can correspond to one or more third-party applications 312A. The third-party application 312A can be an application that registers application information to the virtualization management service 322 to enable application recovery function when executing the above step 501. There is no limitation here.

[0129] 507: The third party application 312A backs up the status and data.

[0130] For example, the third-party application 312A can back up the current running state and generated user data based on the integrated backup and recovery component SDK or call the related services provided by the backup and recovery component. The state and data corresponding to the backup of the third-party application 312A may include the application's page stack and the data saved in the state data saving interface; it may also include the state information of different applications running in the foreground or background, the network connection status, and whether the download task is being executed, etc. It may also include the task currently executed by the application, the currently opened file path, the progress of the currently executed task, etc., which are not limited here.

[0131] The backed-up status and data can be used to restore the relevant page content before the exit when the third-party application 312 is restarted after the unexpected exit, so that the interface before the exit can be restored.

[0132] 508 : The third-party application 312A notifies the native application 311 of the backup completion through the virtualization management service 322 .

[0133] For example, after the third-party application 312A completes the state and data backup process, it can send a notification or feedback message to the virtualization management service 322 to notify itself of the completion of the application running state and data backup. Correspondingly, the virtualization management service 322 can synchronously send a notification of the completion of the backup to the native application 311.

[0134] 509 : The native application 311 notifies the system service 331 that the backup is complete.

[0135] Exemplarily, the native application 311 may send a notification to the system service 331 in response to the notification of completion of the backup sent by the virtualization management service 322 to notify the completion of the backup.

[0136] In addition, after executing the backup process of the above step 504, the native application 311 may also execute this step 509 to notify the system service 331 that the backup is completed.

[0137] It can be understood that the notification process of the above step 508 and step 509 can be synchronous or asynchronous, and there is no limitation here.

[0138] 510: The system service 331 terminates the process of the abnormal application.

[0139] Exemplarily, the processes of the above-mentioned abnormal and erroneous applications may be directly terminated by the system service 331, causing the related applications to exit.

[0140] 511: An abnormal application among the native application 311 and the third-party application 312A exits unexpectedly.

[0141] It can be understood that the execution of the above steps 510 and 511 can be synchronous, that is, when the native application 311 and the third-party application 312A are terminated by the system service 331 due to the above exceptions and errors, the related abnormal application exits unexpectedly. In the embodiment of the present application, the above abnormal application may be any one or more of the above native application 311 and the third-party application 312A, and is not limited here.

[0142] 512 : The system service 331 sends a notification to restart the application to the native application 311 .

[0143] Exemplarily, for a native application 311 that exits unexpectedly, the system service 331 may send a notification to restart the application to the native application 311 based on the detection result of the above step 510. The notification to restart the application may be a notification instructing to restart the native application 311 to resume operation, or it may be a notification instructing to restart the third-party application 312A to resume operation. For the notification instructing to restart the native application 311 to resume operation, the native application 311 may continue to execute the following step 513, apply to the system to create an application process, restart the operation and restore the state and data corresponding to the interface before exiting, etc. For the notification instructing to restart the third-party application 312A to resume operation, the native application 311 may execute the following step 514 and send a notification to the virtualization management service 322 to restart the third-party application 312A.

[0144] 513: The native application 311 restarts and restores the status and data.

[0145] 514 : The native application 311 sends a notification to restart the third-party application to the virtualization management service 322 .

[0146] For example, for the unexpectedly exited third-party application 312A, the native application 311 may send a notification to restart the third-party application 312A to the virtualization management service 322 when receiving the notification to restart the application sent by the system service 331. In this way, the native application 311 may trigger the restart of the related third-party application 312A by calling the virtualization management service 322 to resume operation.

[0147] 515: The virtualization management service 322 creates a process of the third-party application 312A.

[0148] Exemplarily, the virtualization management service 322 may rebuild the application process in the corresponding container or virtual machine based on the received notification of restarting the third-party application, and execute the following step 516 to send a restart instruction to the relevant third-party application 312A to instruct the relevant third-party application 312A to run in the rebuilt application process.

[0149] In other embodiments, the virtualization management service 322 may execute by loading the program code and related data provided by the application package corresponding to the third-party application 312A into the address space of the newly created application process to restart the third-party application 312A, which is not limited here.

[0150] It is understandable that, in the process of restarting the application process to restore the above-mentioned abnormal application that unexpectedly exited and re-entered the operation, the virtualization management service 322 may also request to create other application processes to run other applications related to the abnormal application, or restart the process of running related services, etc. For example, when the process corresponding to the above-mentioned mall application is restarted, the process of the related payment application or payment service may also be restarted.

[0151] 516: The virtualization management service 322 sends a restart instruction to the third-party application 312A.

[0152] Exemplarily, after receiving the notification to restart the third-party application and determining that the running third-party application 312A (including container application or virtual machine application) needs to be restarted, the virtualization management service 322 can send a restart instruction to the relevant third-party application 312A.

[0153] 517: The third-party application 312A restarts and restores the status and data.

[0154] Exemplarily, when the third-party application 312A is restarted and executed in the recreated application process, the page content before the unexpected exit can be restored based on the state and data backed up in the above step 507, so that the electronic device can restore the interface before the exit.

[0155] It can be understood that based on the interactive implementation process of the above steps 501 to 517, the application exception handling method provided by the present application can enable electronic devices such as the above mobile phone 100 to automatically resume operation when running some third-party applications if the application unexpectedly exits. In addition, based on the application exception handling method provided by the present application, some third-party applications can also restore the interface before exiting according to the timely backed-up status and data when resuming operation, thereby providing users with a more coherent user experience.

[0156] As an example, Figure 6a According to an embodiment of the present application, a schematic diagram of an interface when a third-party application is unresponsive and when it resumes operation is shown.

[0157] like Figure 6aAs shown, the mobile phone 100 may receive an operation of the user clicking a checkout control 611 or other controls on the shopping cart interface while displaying the shopping cart interface 610. At this time, the mobile phone 100 may not respond to the user's operation due to insufficient memory or a program code failure of the running mall application. In addition, in this unresponsive state, the shopping cart interface 610 displayed by the mobile phone 100 may appear Figure 6a The interface styles shown in the figure are added with masks or shields, etc., which are not limited here. At this time, the system of the mobile phone 100 may end the process of the mall application and force the mall application to exit.

[0158] Continue to refer Figure 6a As shown, based on the application exception handling method provided in this application, the mall application running on the mobile phone 100 can be restarted after an unexpected exit, and the mobile phone 100 can also restore the interface before the exit. Figure 6a The shopping cart interface 620 shown. At this time, the user can continue to click the settlement control 621 on the restored shopping cart interface 620 to continue the payment operation. In this way, the user's shopping experience using the mobile phone 100 can be more coherent and the use experience will be better.

[0159] In other embodiments, when the mobile phone 100 is running the above-mentioned shopping mall application, if the shopping cart interface of the application is unresponsive due to factors such as insufficient memory, the mobile phone 100 may also display Figure 6b The shopping cart interface 630 is shown. Figure 6b As shown, the shopping cart interface 630 may include a no response prompt window 640. The window 640 may display prompts such as "The mall application is not responding. Do you want to close it?", as well as a "Close application" control 641, a "Wait for response" control 642, etc. When the mobile phone 100 detects that the user clicks the "Close application" control 641, it may trigger an unexpected exit of the mall application. Thereafter, the mobile phone 100 implements the application exception handling method provided in the present application, and may also restart the mall application after the unexpected exit, and the mobile phone 100 may also restore the interface before the exit, for example Figure 6b Shopping cart interface 620 is shown.

[0160] In other embodiments, when the mobile phone 100 is running the above-mentioned shopping mall application, if the shopping cart interface of the application is unresponsive due to factors such as insufficient memory, the mobile phone 100 may also display Figure 6c The desktop 650 or other interface shown. Figure 6cAs shown, the abnormal exit prompt window 660 can be displayed on the desktop 650. The window 660 can display prompts such as "Detected abnormal exit of the mall application, do you want to restore the application?", as well as a restore control 661 and an ignore control 662. When the mobile phone 100 detects that the user clicks the restore control 661, based on the application abnormality handling method provided by the present application, the mobile phone 100 can resume running the mall application, and the mobile phone 100 can also restore the interface before the exit, such as Figure 6c Shopping cart interface 620 is shown.

[0161] It can be understood that the system of the electronic device such as the mobile phone 100 is based on the above Figure 5 In the process of implementing the application exception handling method provided by the present application through the interactive process shown in the figure, the mobile phone 100 and other electronic devices as the execution subject can also implement the following Figure 7 The process shown.

[0162] Figure 7 According to an embodiment of the present application, a schematic diagram of an implementation flow of an application exception handling method is shown. Figure 7 The execution subject of each step in the illustrated process can be an electronic device such as the mobile phone 100, and no limitation is made here.

[0163] Specifically, Figure 7 As shown, the implementation process may include the following steps:

[0164] 701: Display the first interface of the third-party application.

[0165] For example, when the mobile phone 100 runs a third-party application such as the above-mentioned mall application, the relevant interface of the application can be displayed, which is recorded as the first interface. The first interface can be, for example, the above-mentioned Figure 6a The shopping cart interface 610 or other application interfaces shown are not limited here.

[0166] 702: An exception type was detected that may cause a third-party application to exit unexpectedly.

[0167] Exemplarily, based on the above-mentioned anomaly detection component integrated in the system service 331, the mobile phone 100 can detect anomalies and errors caused by insufficient system memory or program code failure of the running application, as well as anomalies caused by unexpected exit of third-party applications due to user memory cleaning or batch management of application running status. These anomalies may cause the relevant third-party applications to be unresponsive and exit unexpectedly. For details, please refer to the execution process of the above-mentioned step 502, which will not be repeated here.

[0168] 703: Notify the native application running the related shell program to back up the status and data.

[0169] 704: Notify related third-party applications of backup status and data through native applications.

[0170] Exemplarily, since the third-party application run by the mobile phone 100 runs in a container or a virtual machine, the system cannot notify the relevant third-party application of detected anomalies and errors, etc., then the native application running the relevant shell program can be notified of the backup status and data. In this way, the native application can call the virtualization management service of the system to notify the relevant third-party application of the backup status and data, etc. For details, please refer to the execution process of the above steps 503 to 507, which will not be repeated here.

[0171] 705: The native application instructs the third-party application that unexpectedly exits to restart and resume operation.

[0172] Exemplarily, the native application running on the mobile phone 100 may receive a notification of restarting the application initiated by the system service after the native application or the related third-party application exits unexpectedly. Correspondingly, the native application may also send a notification instructing the related third-party application to restart and run to the calling virtualization management service, thereby triggering the virtualization management service to initiate the restart and run of the related third-party application process, and instruct the related third-party application to resume running and other processes. For details, please refer to the execution process of the above steps 512 to 516, which will not be repeated here.

[0173] 706: Restart the third-party application and display a second interface based on the backed-up status and data, where the second interface has the same page content as the first interface.

[0174] For example, after the system of the mobile phone 100 rebuilds the process of the third-party application, the third-party application can be restarted to resume operation. At this time, the resumed third-party application can restore the relevant interface before the unexpected exit based on the state and data backed up when the abnormal notification is received, such as the above Figure 6a The shopping cart interface 610 or other application interfaces shown in the figure are not limited here. For details, please refer to the execution process of the above step 517 and the above Figures 6a to 6c The interface shown and related descriptions are not repeated here.

[0175] Example 2

[0176] In the embodiment of the present application, the backup and recovery component SDK is not integrated in the application package of the third-party application 312 developed based on the heterogeneous system. The third-party application 312 can also register application information with the virtualization management service and enable the application recovery function. The third-party application 312 can register application information with the virtualization management service, and can automatically resume operation after an unexpected exit if the application recovery function is enabled.

[0177] Specifically, Figure 8According to an embodiment of the present application, a schematic diagram of an interaction process of an application exception handling method is shown.

[0178] Understandably, Figure 8 The interactive process shown may involve the interaction between the process of the native application 311, the virtualization management service 322, the system service 331, and the process of the third-party application 312. Among them, the shell program of the third-party application 312 can run in the process of the native application 311. In order to distinguish the description from the third-party application 312A integrated with the backup and recovery component SDK mentioned above, in the embodiment of the present application, the third-party application 312 that is not integrated with the backup and recovery component SDK mentioned above can be described as the third-party application 312B below.

[0179] Specifically, Figure 8 As shown, the interaction process may include the following steps:

[0180] 801 : The native application 311 and the third-party application 312B enable the application recovery function to the system service 311 .

[0181] For example, a third-party application 312B that has not integrated the backup and recovery component SDK or does not have the ability to call the corresponding backup and recovery function service can register application information with the virtualization management service 322 to enable the application recovery function. Correspondingly, a third-party application 312B that only registers application information can be automatically restored and started through the virtualization management service 322 provided by this application after an unexpected exit. For details, please refer to the description of the relevant steps below, which will not be repeated here.

[0182] 802: System service 331 performs anomaly detection.

[0183] For example, referring to the above Figure 3 In the structure shown, the system service 331 can detect exceptions and errors caused by factors such as insufficient memory or program code failure during the operation of related applications based on the exception detection component, and can also detect exceptions such as abnormal situations that may cause the third-party application 312B to exit unexpectedly due to operations such as memory cleaning or batch management of application running status by users. Among them, the above exceptions and errors may be caused by factors such as insufficient memory or program code failure of related applications during the system running related applications, and are not limited here.

[0184] It can be understood that the process of abnormality detection by the system service 331 can be performed based on the application information registered when the native application 311 and the third-party application 312B enable the application recovery function. For example, the system service 331 can obtain relevant system logs or application logs based on the application information of one or more applications in the native application 311 and the third-party application 312B to determine whether an abnormality or error occurs. This will not be elaborated here.

[0185] 803 : The system service 331 sends an exception notification to the native application 311 .

[0186] Exemplarily, when the system service 311 detects that one or more of the native applications 311 and the third-party applications 312B have abnormalities such as exceptions and errors during operation, or that the user performs memory cleaning or batch management of application running status operations, etc., which may cause the third-party application 312B to exit unexpectedly, an abnormality notification may be sent to the relevant native application 311. The abnormality notification may carry application information of the application where the abnormality occurs, such as the AID of the native application 311 and / or the third-party application 312B, so that the native application 311 can identify or determine the application where the abnormality occurs.

[0187] It can be understood that the shell program running in the process of the native application 311 can provide an interface for one or more third-party applications 312B developed based on the same system. Therefore, the native application 311 can determine the third-party application 312B where the exception occurs and notify the virtualization management service 322 based on the running shell program and the application information carried by the received exception notification, so that the virtualization management service 322 sends relevant exception notifications to the relevant third-party applications 312B.

[0188] 804: Native application 311 backs up state and data.

[0189] The backup process performed in step 804 is the same as that in the above embodiment 1. Figure 5 The backup process performed in step 504 is the same as shown. For details, please refer to the relevant description of step 504 in the above embodiment 1, which will not be repeated here.

[0190] 805 : The native application 311 notifies the system service 331 that the backup is complete.

[0191] 806 : The native application 311 sends an exception notification to the third-party application 312B through the virtualization management service 322 .

[0192] Exemplarily, when the native application 311 determines that the received exception notification corresponds to an application indicating an exception as a third-party application 312B, the native application 311 can send an exception notification to the virtualization management service 322. Furthermore, the virtualization management service 322 can further send an exception notification to the relevant third-party application 312B based on the application information carried in the exception notification.

[0193] 807: The virtualization management service 322 records relevant third-party application information.

[0194] The virtualization management service 322 specifically performs the process of recording relevant third-party application information. Please refer to the relevant description in step 506 in the above embodiment 1, and will not be repeated here.

[0195] It can be understood that the relevant third-party application information recorded by the virtualization management service 322 can correspond to one or more third-party applications 312B, which can be the third-party application 312B that registers application information with the virtualization management service 322 when executing the above step 801, etc., and there is no limitation here.

[0196] It can be understood that the execution process of the above step 803 and steps 804 to 807 can be synchronous or asynchronous, and there is no limitation here.

[0197] 808: The system service 331 terminates the process of the abnormal application.

[0198] The backup process performed in step 808 is the same as that in the above embodiment 1. Figure 5 The backup process performed in step 510 is the same. For details, please refer to the relevant description in the above step 510, which will not be repeated here.

[0199] 809: An abnormal application among the native application 311 and the third-party application 312B exits unexpectedly.

[0200] Exemplarily, in the embodiment of the present application, the abnormal application may be any one or more of the native application 311 and the third-party application 312B, which is not limited here.

[0201] 810 : The system service 331 sends a notification to restart the application to the native application 311 .

[0202] Exemplarily, for a native application 311 that exits unexpectedly, the system service 331 may send a notification to restart the application to the native application 311 based on the detection result of step 808 above. The notification to restart the application may be a notification instructing to restart the native application 311 to resume operation, or it may be a notification instructing to restart the third-party application 312B to resume operation. For the notification instructing to restart the native application 311 to resume operation, the native application 311 may continue to execute the following step 811, apply to the system to create an application process, restart the operation, and restore the state and data corresponding to the interface before exiting, etc. For the notification instructing to restart the third-party application 312B to resume operation, the native application 311 may execute the following step 812 and send a notification to the virtualization management service 322 to restart the third-party application 312B.

[0203] 811: The native application 311 restarts and restores the status and data.

[0204] 812 : The native application 311 sends a notification to restart the third-party application to the virtualization management service 322 .

[0205] For example, for the unexpectedly exited third-party application 312B, the native application 311 may send a notification to restart the third-party application 312B to the virtualization management service 322 when receiving the notification to restart the application sent by the system service 331. In this way, the native application 311 may trigger the restart of the related third-party application 312B by calling the virtualization management service 322 to resume operation.

[0206] 813: The virtualization management service 322 restarts the process of the third-party application 312B.

[0207] Exemplarily, the virtualization management service 322 may initiate a request to the system to create an application process based on the received notification of restarting the third-party application, and execute the following step 516 to send a restart instruction to the relevant third-party application 312B to instruct the relevant third-party application 312B to run in the recreated application process.

[0208] 814: The virtualization management service 322 sends a restart instruction to the third-party application 312B.

[0209] Exemplarily, after receiving the notification of restarting the third-party application and determining that the running third-party application needs to be restarted, the virtualization management service 322 may send a restart instruction to the related third-party application 312B.

[0210] 815: The third-party application 312B restarts and runs.

[0211] It can be understood that based on the interactive implementation process of the above steps 801 to 815, the application exception handling method provided in the present application can enable electronic devices such as the above-mentioned mobile phone 100 to resume operation automatically when running some third-party applications if an application exits unexpectedly, thereby providing users with a more consistent user experience to a certain extent.

[0212] Fig. 9 According to an embodiment of the present application, a structural schematic diagram of an electronic device is shown.

[0213] like Fig. 9 As shown, the electronic device 900 may include an anomaly detection component and a backup recovery component.

[0214] Among them, the anomaly detection component is used to perform the related functions of "detecting anomalies and errors and issuing anomaly notifications". For details, please refer to the above Figure 3 A description of the functions of the anomaly detection component integrated in the system service 331 is shown, and Figure 5 The descriptions of steps 502 to 503 in the interactive process are not repeated here.

[0215] The backup and restore component is used to perform backup and restore related functions of the state and data of native applications and / or third-party applications. For details, please refer to the above Figure 3 The native application 311 and the third-party application 312 shown in the figure enable the application recovery function based on the backup recovery component, and Figure 5 The descriptions of step 504, step 507, step 513, and step 517 in the interactive process are not repeated here.

[0216] Continue to refer Fig. 9 As shown, in other embodiments, the structure of the electronic device 100 may also include an abnormality detection component, a backup component and a recovery component. The backup component and the recovery component may be used to perform the state and data backup function and the state and data recovery function respectively.

[0217] Specifically, refer to Fig. 9 As shown, the backup component can be used to perform the process of "backing up the state and data of native applications" and "backing up the state and data of third-party applications". The recovery component can be used to perform the process of "restoring the state and data of native applications" and "restoring the state and data of third-party applications".

[0218] Fig.10 According to an embodiment of the present application, a schematic diagram of the hardware structure of an electronic device is shown.

[0219] The electronic device 900 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identity module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

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

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

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

[0223] In the embodiment of the present application, the processor 110 can complete the above Figure 7The reading and execution control of the relevant instructions of each step of the process shown in the figure implements the application exception handling method provided by this application. For the specific implementation process, please refer to the above Figure 7 The detailed description of each step in the process shown above Figure 5 , Figure 8 The related descriptions in the interactive process shown are not limited here.

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

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

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

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

[0228] The charging management module 140 is used to receive charging input from the charger. The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160.

[0229] The wireless communication function of the electronic device 900 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

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

[0231] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The electronic device 900 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor. Among them, the camera 193 is used to capture a static image or a video. In some embodiments, the electronic device 900 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0232] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 900. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

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

[0234] In the embodiment of the present application, the executable program code stored in the internal memory 121 may include relevant instructions for implementing the application exception handling method provided by the present application, etc. The specific implementation process can refer to the above Figures 2 to 7 The above and related descriptions will not be repeated here.

[0235] The electronic device 900 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

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

[0237] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

[0238] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.

[0239] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to or disconnected from the electronic device 900 by inserting the SIM card interface 195 or removing the SIM card from the SIM card interface 195 .

[0240] The embodiments of the present application also provide a computer program product for implementing the application exception handling methods provided in the above embodiments.

[0241] The various embodiments of the mechanism disclosed in the present application can be implemented in hardware, software, firmware or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program module or module code executed on a programmable system, and the programmable system includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device and at least one output device.

[0242] A computer program module or module code can be applied to input instructions to perform the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.

[0243] Module code can be implemented with high-level modular language or object-oriented programming language to communicate with the processing system. When necessary, module code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.

[0244] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, instructions may be distributed over a network or through other computer-readable media. Therefore, a machine-readable medium may include any mechanism for storing or transmitting information in a machine (e.g., computer) readable form, including, but not limited to, a floppy disk, an optical disk, an optical disk, a magneto-optical disk, a read-only memory (ROM), a random access memory (RAM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic card or an optical card, a flash memory, or a tangible machine-readable memory for transmitting information (e.g., a carrier wave, an infrared signal, a digital signal, etc.) using the Internet in an electrical, optical, acoustic, or other form of propagation signal. Accordingly, machine-readable media include any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a form readable by a machine (eg, a computer).

[0245] References to "one embodiment" or "an embodiment" in the specification mean that the specific features, structures, or characteristics described in conjunction with the embodiment are included in at least one exemplary implementation or technology disclosed according to the embodiment of the present application. The appearance of the phrase "in one embodiment" in various places in the specification does not necessarily all refer to the same embodiment.

[0246] The disclosure of the embodiment of the present application also relates to an operating device for executing the text. The device can be specially constructed for the required purpose or it can include a general-purpose computer selectively activated or reconfigured by a computer program stored in the computer. Such a computer program can be stored in a computer-readable medium, such as, but not limited to any type of disk, including a floppy disk, an optical disk, a CD-ROM, a magneto-optical disk, a read-only memory (ROM), a random access memory (RAM), an EPROM, an EEPROM, a magnetic or optical card, an application-specific integrated circuit (ASIC) or any type of medium suitable for storing electronic instructions, and each can be coupled to a computer system bus. In addition, the computer mentioned in the specification may include a single processor or may be an architecture involving multiple processors for increased computing power.

[0247] In addition, the language used in this specification has been primarily selected for readability and instructional purposes and may not be selected to describe or limit the disclosed subject matter. Therefore, the present application embodiment disclosure is intended to illustrate rather than limit the scope of the concepts discussed herein.

Claims

1. An application exception handling method, applied to electronic equipment, characterized in that: A first operating system, a first application developed based on the first operating system, and a second application developed based on the second operating system are installed on the electronic device; and The method comprises: displaying a first interface of the second application, wherein a shell program of the second application runs in a first process of the first application; The second application exits abnormally; Restore display of the first interface of the second application.

2. The method according to claim 1, characterized in that The restoring and displaying the first interface of the second application includes: The second application receives an exception notification at a first moment, and saves a first state and first user data corresponding to the display content of the first interface, wherein the first moment is earlier than a second moment when the second application exits abnormally, and the first state includes at least a page stack corresponding to the display content of the first interface and data saved in a state data saving interface; The second application exits abnormally at the second moment, and the first interface is generated based on the first state and the first user data.

3. The method according to claim 2, characterized in that The first application is a native application, the second application includes a container application or a virtual machine application, the electronic device includes a first service for managing the container or the virtual machine, and, The second application receives an abnormal notification at a first moment, including: The second application receives a first exception notification sent by the first service, wherein the first exception notification is generated by the first service in response to a second exception notification sent by the first application.

4. The method according to claim 3, characterized in that The electronic device includes a second service, and, The method comprises: detecting, through the second service, a fault related to the operation of the second application, and sending a third abnormality notification to the first application; In response to the third exception notification, the first application sends a second exception notification to the first service.

5. The method according to claim 4, characterized in that The type of the fault related to the running of the second application includes any one of the following: JS_CRASH;CPP_CRASH;APP_FREEZE;KILL.

6. The method according to claim 3, characterized in that The second application exits abnormally, including: a second process of the second application running in the first container or the first virtual machine is abnormally terminated, wherein the first container is used to provide an execution environment for the container application in the first operating system, and the first virtual machine is used to provide an execution environment for the virtual machine application in the first operating system; and The first process of the first application is abnormally terminated.

7. The method according to claim 6, characterized in that The restoring and displaying the first interface of the second application includes: In response to the restart notification sent by the first application, the first service creates a third process in the first container and sends a restart instruction to the second application; In response to the restart instruction, the second application restarts running in the third process to generate and resume displaying the first interface.

8. The method according to claim 5, characterized in that The restoring and displaying the first interface of the second application includes: In response to the user restarting the second application, the second application starts running and resumes displaying the first interface.

9. The method according to any one of claims 3 to 8, characterized in that The exception type of the first exception notification includes any one of the following: Exceptions caused by insufficient memory; Exceptions caused by at least one of the following failures: JS_CRASH, CPP_CRASH, APP_FREEZE, KILL; Exceptions caused by user-instructed operations such as clearing memory or ending application processes in batches.

10. The method according to claim 1, characterized in that The electronic device further includes a third application developed based on a third operating system, the third operating system is of a different type from the second operating system; and The shell program of the third application runs in a fourth process of a fourth application, and the fourth application is a native application developed based on the first operating system.

11. The method according to any one of claims 1 to 10, characterized in that The first operating system and the second operating system are of different types, and The types of the first operating system and the second operating system include any one of the following: OpenHarmony TM ;HarmonyOS TM ;Linux TM ;Android TM ;Windows TM ;Mac TM 。 12. An electronic device, characterized in that: include: one or more processors; One or more memories; the one or more memories store one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device executes the application exception handling method described in any one of claims 1 to 11.

13. A computer readable medium, characterized in that The readable medium stores instructions, and when the instructions are executed on a computer, the computer executes the application exception handling method according to any one of claims 1 to 11.