Method for restoring factory settings and electronic device

By detecting the device status and communication connection and adjusting the restart strategy, the problem of electronic devices not being able to boot normally during factory reset is solved, and efficient restart of the device and optimization of user experience is achieved.

CN118467254BActive Publication Date: 2024-11-26HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410909594.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-11-26
Estimated Expiration
2044-07-08

AI Technical Summary

Technical Problem

During the factory reset of electronic devices, the device cannot boot normally, resulting in poor user experience, especially when the device has a communication connection with other devices, the file system encryption fails, resulting in a failed restart.

Method used

By checking whether the device is in the factory reset state and the communication connection with other devices, adjust the restart strategy, skip the non-start scheme, and perform normal startup operations to ensure that the device can restart normally in special recovery scenarios.

Benefits of technology

It improves the accuracy and efficiency of electronic devices during factory reset, ensures that users can use the device normally, and optimizes the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118467254B_ABST
    Figure CN118467254B_ABST
Patent Text Reader

Abstract

A method for restoring factory settings and an electronic device, relating to the field of electronic technology, the method comprising: a first electronic device performs a first restart in response to an instruction issued by a user to instruct the first electronic device to restore factory settings. After the first restart is successful, the recovery mode is entered, a formatting operation is performed, user data is cleared, and a factory restore flag is set to a first state value. Then, a second restart is performed. During the second restart, if it is detected that the file system encryption fails, when it is determined that the first electronic device is in a state of restoring factory settings and there is a communication connection between the first electronic device and the second electronic device, the non-booting scheme is skipped, the booting operation is performed, and the second restart of the first electronic device is successful. Thereby achieving the purpose of the first electronic device normally completing the factory restoration in a special recovery scenario, and improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of electronic technology, and more particularly to a method for restoring factory settings and an electronic device. Background Art

[0002] At present, the usage rate of electronic devices is getting higher and higher. However, after the electronic devices are manufactured, due to some problems that are not easy to appear in the research and development stage, as well as the freezing problem of the operating system used by the electronic devices, some abnormalities often occur during the use of the electronic devices, making it inconvenient to use the electronic devices after turning them on or unable to use them normally. At this time, a simple and effective method is to restore the factory settings of the electronic devices so that the relevant data in the electronic devices can be restored, thereby restoring the state of the electronic devices to the original state, so that users can use the electronic devices normally.

[0003] During the process of restoring the factory settings of an electronic device, the electronic device may fail to boot normally, which affects the use of the electronic device and brings a poor experience to the user. Summary of the invention

[0004] The embodiments of the present application provide a method for restoring factory settings and an electronic device, which can adjust the restart strategy when the electronic device is in a state of restoring factory settings and has a communication connection between the electronic device and other devices, so that the electronic device can more accurately identify special recovery scenarios when restoring factory settings, execute corresponding normal startup solutions, and optimize the user experience of the electronic device.

[0005] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:

[0006] In a first aspect, a method for restoring factory settings is provided, and the method is applied to a first electronic device. The method includes: the first electronic device performs a first restart in response to a first operation, wherein the first operation is used to instruct the first electronic device to restore factory settings. After the first restart is successful, the first electronic device enters a recovery mode, and then the first electronic device performs a recovery processing operation. Then, the first electronic device starts to restart for a second time. During the second restart, if it is detected that the file system encryption fails, the second restart of the first electronic device is successful if a preset condition is met. Wherein, the preset condition includes: determining that the first electronic device is in a state of restoring factory settings, and there is a communication connection between the first electronic device and the second electronic device. Wherein, the communication connection includes a wired connection and / or a wireless connection.

[0007] In the above-mentioned method for restoring factory settings, even if the file system encryption failure is detected during the process of restoring factory settings, it can be judged that the first electronic device is in a special recovery scenario of restoring factory settings based on the fact that the first electronic device is in a state of restoring factory settings and that there is a communication connection between the first electronic device and the second electronic device. At this time, the first electronic device can skip the no-boot strategy, perform a normal boot operation, and successfully restart the first electronic device, so that in the special recovery scenario of restoring factory settings, the first electronic device can be successfully powered on and the user may use it normally. In other words, through this solution, it is conducive to adjusting and optimizing the process of restoring factory settings, thereby improving the accuracy and efficiency of restoring factory settings of the first electronic device.

[0008] During the process of restoring factory settings, if data is written to the first electronic device based on the communication connection between the first electronic device and the second device, the file system encryption will fail. In this special recovery scenario, the first electronic device should also be able to start normally. The embodiment of the present application can improve the accuracy of identifying the data written by the second electronic device in the first electronic device by judging whether there is a wired communication connection between the first electronic device and the second electronic device, which is conducive to improving the accuracy of identifying the first electronic device in a special recovery scenario. Therefore, in the special recovery scenario, the first electronic device is restarted normally, so that the first electronic device is restarted successfully for the second time.

[0009] In a possible implementation manner of the first aspect, the communication connection in the above-mentioned preset condition may include a wired connection. For example, the wired connection includes a Universal Serial Bus (USB) connection.

[0010] It is understandable that, during the process of restoring factory settings, if data is written to the first electronic device, the file system encryption will fail, and in this special recovery scenario, the first electronic device should also be able to start normally. The embodiment of the present application can improve the accuracy of identifying the presence of data written by the second electronic device based on the wired connection in the first electronic device by judging whether there is a wired connection between the first electronic device and the second electronic device, thereby facilitating the accuracy of identifying that the first electronic device is in a special recovery scenario.

[0011] In another possible implementation of the first aspect, after entering the recovery mode, the method further includes: the first electronic device sets a factory restore flag to a first state value, the first state value is used to indicate that the first electronic device is in a state of restoring factory settings, and the above-mentioned determination that the first electronic device is in a state of restoring factory settings includes: detecting that the factory restore flag is the first state value. For example, the first state value may be 1, which is used to indicate that the first electronic device is in a state of restoring factory settings. The factory restore flag clearly indicates whether the first electronic device is in a state of restoring factory settings, which is conducive to improving the accuracy of determining that the above-mentioned first electronic device is in a special recovery scenario. In this implementation, the special recovery scenario is more effectively determined, which is conducive to reducing the misjudgment of the first electronic device when restoring factory settings, and further conducive to improving the convenience of restoring the factory settings of the first electronic device.

[0012] In another possible implementation of the first aspect, when performing a recovery processing operation, it includes: the first electronic device performs a formatting processing operation to delete the data in the user data file in the file system; setting the factory restore flag to a first state value, including: after the above-mentioned deletion of the data in the user data file in the file system, setting the factory restore flag to the first state value, clearing the data in the user data file through formatting processing, and then setting the factory restore flag, thereby indicating that the first electronic device is in a factory reset state, which is beneficial to improving the accuracy of identifying the factory reset state.

[0013] In another possible implementation of the first aspect, the method further includes: after the first electronic device successfully restarts for the second time, setting the factory reset flag to a second state value. For example, the second state value may be 0, which indicates that the first electronic device is not in a factory reset state. Changing the factory reset flag to the second state value is conducive to reducing the probability of misjudgment of the state of the first electronic device.

[0014] In another possible implementation of the first aspect, the method further includes: when the file system encryption failure is detected, the first electronic device fails to restart for the second time if the above-mentioned preset conditions are not met. Wherein, the preset conditions include: the factory restore flag is a first state value, and there is a USB communication connection between the first electronic device and the second electronic device. Through the above method, when the file system encryption failure is detected, and the factory restore flag is not the first state value and / or there is no USB communication connection between the first electronic device and the second electronic device, it is determined that the first electronic device does not meet the preset conditions and is not currently in the above-mentioned special recovery scenario, and then the first electronic device cannot be restarted, and the second restart fails.

[0015] In another possible implementation of the first aspect, the second successful restart of the first electronic device includes: when the preset conditions are met, the first electronic device skips the execution of the non-startup solution, and the second successful restart. It should be understood that when the preset conditions are not met, the first electronic device executes the non-startup solution, and the second restart fails. Through the above method, the first electronic device determines to skip the non-startup solution according to the preset conditions, which is conducive to improving the efficiency and accuracy of the first electronic device executing the corresponding restart result when the second restart is performed.

[0016] In another possible implementation of the first aspect, the foreground application running on the second electronic device has the ability to write data to the first electronic device through a communication connection. In this case, it is very likely that the second electronic device writes data to the first electronic device through a communication connection. The failure of the file system encryption of the first electronic device may be caused by the second electronic device writing data to the first electronic device, and the first electronic device is in the above-mentioned special recovery scenario of restoring factory settings. It should be understood that the foreground application may include system applications and third-party applications, including but not limited to screen projection software applications, file transfer applications, etc.

[0017] In another possible implementation of the first aspect, the first electronic device performs a recovery processing operation, including: the first electronic device performs a formatting processing operation to delete data in a user data file in the file system; during the second restart process, the first electronic device detects that the file system encryption fails, including: during the second restart process, the first electronic device detects that the user data file in the file system is not empty and the file system encryption fails.

[0018] In another possible implementation of the first aspect, during the second restart process, the user data file includes data received from the second electronic device based on the communication connection, and the data may be text, audio, video, etc. When the first electronic device has a communication connection with the second electronic device, and the first electronic device may have data written based on the communication connection, the first electronic device will detect that the file system encryption fails. Further, the first electronic device detects the factory restore flag and the USB connection status, skips the non-booting scheme according to the detection result, and after executing the booting operation, determines that the second restart of the first electronic device is successful. The above method is conducive to improving the efficiency of restoring the factory settings of the first electronic device.

[0019] In another possible implementation of the first aspect, if it is detected that the file system encryption is successful, the first electronic device normally executes the process of restoring factory settings, and the second restart is successful.

[0020] In another possible implementation of the first aspect, the first electronic device includes a user space module and a kernel module, and when the first electronic device detects that the file system encryption fails, it includes: detecting the file system encryption failure through the user space module. After formatting the user data file through the user space module of the first electronic device, when the file system encryption failure is detected, controlling the kernel module to perform further operations is conducive to improving the efficiency of restoring the first electronic device to factory settings.

[0021] Wherein, in the above method, the first electronic device is restarted for the second time, and it can be understood that the second restart is successful, including: starting the operating system of the first electronic device through the above kernel module, and the second restart is successful. It should be noted that restarting can be understood as restarting the operating system of the first electronic device after shutting down.

[0022] The step of setting the factory restore flag bit to the first state value comprises: setting the factory restore flag bit to the first state value through the kernel module.

[0023] In a second aspect, an electronic device is provided, comprising: a memory, one or more processors; the memory and the processor are coupled; wherein computer program code is stored in the memory, and the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the method for restoring factory settings as described in any one of the above-mentioned first aspect.

[0024] In a third aspect, a computer-readable storage medium is provided, comprising computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method for restoring factory settings as described in any one of the first aspects.

[0025] In a fourth aspect, a computer program product is provided. When the computer program product is run on a computer, the computer executes the method for restoring factory settings as described in any one of the first aspects above.

[0026] It can be understood that the beneficial effects that can be achieved by the electronic device described in the second aspect, the computer-readable storage medium described in the third aspect, and the computer program product described in the fourth aspect provided above can be referred to the beneficial effects in the first aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 A schematic diagram of restoring factory settings provided in an embodiment of the present application;

[0028] Figure 2 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;

[0029] Figure 3 A schematic diagram of the software structure of an electronic device provided in an embodiment of the present application;

[0030] Figure 4 A flowchart of a method for restoring factory settings provided in an embodiment of the present application;

[0031] Figure 5 A schematic diagram of a display interface for restoring factory settings provided in an embodiment of the present application;

[0032] Figure 6 A schematic diagram of a display interface for another factory reset scenario provided in an embodiment of the present application;

[0033] Figure 7 A schematic diagram of a display interface for another factory reset scenario provided in an embodiment of the present application;

[0034] Figure 8 A flowchart of another method for restoring factory settings provided in an embodiment of the present application;

[0035] Fig. 9 A schematic diagram of another method of restoring factory settings provided in an embodiment of the present application;

[0036] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0037] The technical solution in the embodiment of the present application will be described below in conjunction with the drawings in the embodiment of the present application. Among them, in the description of the present application, unless otherwise specified, " / " indicates that the objects associated before and after are in an "or" relationship, for example, A / B can represent A or B; "and / or" in the present application is only a description of the association relationship of the associated objects, indicating that there can be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. And, in the description of the present application, unless otherwise specified, "multiple" refers to two or more than two. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple. In addition, in order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, the words "first", "second" and the like are used to distinguish the same items or similar items with substantially the same functions and effects. It can be understood by those skilled in the art that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like do not limit the number and execution order. In the following, the terms "first" and "second" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present embodiment, unless otherwise specified, the meaning of "multiple" is two or more. At the same time, in the embodiments of the present application, the words "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or design schemes. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way for easy understanding.

[0038] During the process of restoring the factory settings of a first electronic device such as a mobile phone, it will be restarted twice. The second restart often fails. After the first restart, if the first electronic device detects that the file system encryption fails, the relevant technology will execute the non-booting solution, and the second restart of the first electronic device will fail, and the user cannot use the first electronic device normally.

[0039] During the factory reset process, if the second electronic device writes data to the first electronic device, the file system encryption of the first electronic device will fail, which will cause the second restart of the first electronic device to fail. Figure 1As shown, during the process of restoring the factory settings, there is a communication connection between the first electronic device and the second electronic device, and the second electronic device is likely to write data to the first electronic device, resulting in the failure of the file system encryption of the first electronic device, the failure of the second restart, and the inability to complete the factory settings restoration normally.

[0040] In this case, if the user disconnects the communication connection between the first electronic device and the second electronic device, restarts it again, and restores the factory settings of the first electronic device again, the factory settings can be restored normally again. At this time, the time for restoring the factory settings of the first electronic device is relatively long, which affects the situation of restoring the factory settings of the first electronic device, and further affects the user experience when using the factory settings restoration function. Importantly, the user does not actually know that he needs to disconnect the communication connection and then restore the factory settings again, and usually thinks that the first electronic device has failed and can no longer be used normally.

[0041] In fact, during the process of restoring factory settings, when the second electronic device writes data to the first electronic device, it should also be ensured that the first electronic device can restart normally, so as to complete the factory settings restoration normally. During the process of restoring factory settings (also referred to as being in the factory settings restoration state or in the factory settings restoration state), when the second electronic device has a communication connection with the first electronic device, the failure of the first electronic device's file system encryption is likely to be caused by the second electronic device writing data to the first electronic device based on the communication connection. Therefore, during the process of restoring factory settings, the first electronic device detects that the file system encryption fails and there is a communication connection between the first electronic device and the second electronic device, which can be considered a special recovery scenario. In this special recovery scenario, it should be ensured that the first electronic device can restart normally and complete the factory settings restoration normally.

[0042] In order to avoid the problem that the first electronic device cannot normally complete the factory settings restoration when it is in a special restoration scenario when restoring the factory settings, a method for restoring the factory settings is provided in an embodiment of the present application. The method can be applied to a first electronic device, and there is a communication connection between the first electronic device and the second electronic device. In the method, the first electronic device performs a first restart in response to an instruction issued by a user to instruct the first electronic device to restore the factory settings. After the first restart is successful, the first electronic device enters the recovery mode. Then, the first electronic device restarts for the second time. During the second restart, if the first electronic device detects that the file system encryption fails, when it is determined that the first electronic device is in a state of restoring the factory settings, and there is a communication connection between the first electronic device and the second electronic device, the first electronic device is in a special recovery scenario, so as to perform a power-on operation, and the second restart of the first electronic device is successful, and the first electronic device is normally powered on. Through the above method, when the first electronic device is in a special recovery scenario in restoring the factory settings, the non-power-on scheme can be skipped, or the non-power-on scheme can be set to METHOD_OD_NOTING, and the power-on operation can be directly performed, and the method for restoring the factory settings of the first electronic device is optimized, which is conducive to improving the user experience when performing the factory settings restoration operation on the first electronic device.

[0043] Specifically, the communication connection between the second electronic device and the first electronic device used to determine whether they are in the special recovery scenario may include a wired connection and / or a wireless connection. That is, if the first electronic device is in the factory reset state and has a wired connection or a wireless connection, the first electronic device sets the no-boot scheme to METHOD_OD_NOTING, skips the no-boot scheme, and directly performs the boot operation, and the second restart of the first electronic device is successful.

[0044] In a possible implementation, the communication connection used to determine whether it is in the special recovery scenario is a wired connection, and the wired connection can be a universal serial bus USB connection. The first electronic device performs a first restart in response to an instruction issued by a user to instruct the first electronic device to restore factory settings. The first electronic device enters recovery mode after the first restart is successful. In recovery mode, a formatting operation is performed, user data is cleared, and the factory restore flag is set to a first state value. Then, the first electronic device restarts for a second time. During the second restart, after the first electronic device detects that the file system encryption fails, the first electronic device determines that the factory restore flag is the first state value, and the first electronic device detects the presence of the USB interface. When the USB interface is in place, it is determined that there is a communication connection between the first electronic device and the second electronic device; when the USB interface is not in place, it is determined that there is no communication connection between the first electronic device and the second electronic device. It can be understood that the wired connection may include but is not limited to a USB connection, which is not limited here.

[0045] In a possible implementation, the communication connection used to determine whether it is in the special recovery scenario is a wireless connection, and the wireless connection can be a near-field wireless communication (NFC) connection. The first electronic device performs a first restart in response to an instruction issued by a user to instruct the first electronic device to restore factory settings. After the first restart is successful, the first electronic device enters recovery mode, performs a formatting operation, clears user data, and sets the factory restore flag to a first state value. Then, the first electronic device restarts for a second time. During the second restart, after the first electronic device detects that the file system encryption fails, the first electronic device determines that the factory restore flag is the first state value, and there is an NFC connection between the first electronic device and the second electronic device. The first electronic device skips the non-booting solution and performs a booting operation, and the second restart of the first electronic device is successful. It can be understood that the wireless connection may include but is not limited to an NFC connection, which is not limited here.

[0046] In some embodiments, the foreground application of the second electronic device has the ability to write data to the first electronic device through a communication connection. In this case, if the file system encryption fails during the factory reset process, and there is a communication connection between the first electronic device and the second electronic device, it is most likely caused by the foreground application of the second electronic device writing data to the first electronic device. The current scenario is a special recovery scenario, and the boot operation should be performed normally. For example, the foreground application can be system software or third-party software such as screen projection software and file transfer software, and the data written by the second electronic device to the first electronic device can be video, text, pictures, audio, animation, animated graphics and other data. In other words, when the first electronic device is in the factory reset state, the second electronic device writes data to the first electronic device, which will cause the first electronic device to fail to encrypt when performing the file system encryption operation. At this time, the first electronic device is in a special recovery scenario, and the first electronic device can skip the non-boot solution and directly perform the boot operation.

[0047] The method for restoring factory settings provided in the embodiment of the present application can be applied to the above-mentioned first electronic device. Exemplarily, the first electronic device can be a mobile phone, a smart device, a wearable electronic device (such as a smart watch), a tablet computer, and other electronic devices that support communication connection; the second electronic device can be a TV, a laptop, a car computer, a personal computer (personal computer, PC), an augmented reality (augmented reality, AR)\virtual reality (virtualreality, VR) device, a car computer, and other electronic devices. The embodiment of the present application does not impose any special restrictions on the specific forms of the first electronic device and the second electronic device. In some embodiments, the second electronic device can support screen projection display.

[0048] Please refer to Figure 2 , which shows a schematic diagram of the structure of an electronic device 100 (which may be the first electronic device or the second electronic device) provided in an embodiment of the present application. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, 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 identification module (SIM) card interface 195, etc.

[0049] Among them, the above-mentioned sensor module 180 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor 180A, a temperature sensor, a touch sensor 180B, an ambient light sensor, a bone conduction sensor, etc.

[0050] 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 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate 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.

[0051] 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 memory, a video codec, a digital signal processor (DSP), a baseband processor, a neural-network processing unit (NPU), and / or a micro controller unit (MCU), etc. Different processing units may be independent devices or integrated in one or more processors.

[0052] In some embodiments, the processor may be configured to process instruction information issued by a user to restore the first electronic device to factory settings.

[0053] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0054] In some embodiments, the controller can be used to control the first electronic device to restart for the first time and restart for the second time. The controller can also be used to control the first electronic device to enter a recovery mode, and control the first electronic device to perform file system encryption.

[0055] 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.

[0056] In some embodiments, the memory may be used to store data written by the second electronic device to the first electronic device.

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

[0058] 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 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0059] 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, and provides power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0060] The wireless communication function of the electronic device 100 can be implemented by antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modulation and demodulation processor and baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antenna. For example, antenna 1 can be reused as a diversity antenna of a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0061] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The wireless communication module 160 can provide solutions for wireless communications including wireless local area networks (WLAN) (such as Wi-Fi networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), NFC, infrared technology (IR), etc., applied to the electronic device 100.

[0062] The electronic device 100 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.

[0063] The display screen 194 is used to display images, videos, etc. The display screen is a touch screen. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

[0064] Exemplarily, when the electronic device 100 is the first electronic device in the aforementioned embodiment, the display screen 194 of the first electronic device can be used to display prompt information for restoring the factory settings of the first electronic device.

[0065] Exemplarily, when the electronic device 100 is the second electronic device in the aforementioned embodiment, the display screen 194 of the second electronic device can be used to display the interface content of the foreground application of the second electronic device.

[0066] The electronic device 100 can realize the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194 and the application processor. The ISP is used to process the data fed back by the camera 193. The camera 193 is used to capture a static image or a video. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0067] 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 100. 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.

[0068] The internal memory 121 can be used to store computer executable program codes, and the above-mentioned executable program codes include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can 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 can store data created during the use of the electronic device 100 (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.

[0069] The electronic device 100 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.

[0070] The fingerprint sensor 180A is used to collect fingerprint information. The electronic device 100 can use the fingerprint characteristics of the collected fingerprint information to verify the user's identity (i.e., fingerprint recognition) to achieve fingerprint unlocking, access to application locks, fingerprint photography, fingerprint answering calls, etc.

[0071] In the embodiment of the present application, the fingerprint sensor 180A can be arranged under the display screen 194; or, the fingerprint sensor 180A can be integrated in the display screen 194. The fingerprint sensor 180A can be arranged at a fixed position of the display screen 194. For example, when the electronic device 100 is a touch screen mobile phone, the fingerprint sensor 180A can be arranged at a position close to the lower side of the touch screen mobile phone in the touch screen (i.e., the display screen 194) of the touch screen mobile phone. Alternatively, the fingerprint sensor 180A can be arranged in the entire display screen 194.

[0072] The touch sensor 180B is also called a "touch panel (TP)". The touch sensor 180B can be set on the display screen 194, and the touch sensor 180B and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180B is used to detect touch operations acting on or near it. For example, the touch sensor can detect that the user touches the "restore factory settings" button. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180B can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.

[0073] The buttons 190 include a power button, a volume button, etc. The motor 191 can generate a vibration prompt. The indicator 192 can be an indicator light, which can be used to indicate the charging status, power change, messages, missed calls, notifications, etc. The SIM card interface 195 is used to connect a SIM card.

[0074] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system of the layered architecture is taken as an example to exemplify the software structure of the electronic device 100.

[0075] Figure 3 Schematic diagram of the software structure of the electronic device 100 according to an embodiment of the present invention.

[0076] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.

[0077] The application layer can include a series of application packages.

[0078] like Figure 3As shown, the application package may include applications such as camera, gallery, calendar, call, setting, navigation, WLAN, Bluetooth, music, video, short message, etc.

[0079] Exemplarily, when the electronic device 100 is the first electronic device in the aforementioned embodiment, the setting application includes a function of supporting the first electronic device to perform factory reset. In some embodiments, the application package may also include a screen projection application that supports communication with the second electronic device, an application that supports displaying the progress and / or results of factory reset, etc.

[0080] Exemplarily, when the electronic device 100 is the second electronic device in the aforementioned embodiment, the application package may also include a video application supporting the screen projection function, an application supporting the playback of screen projection videos, and an application for implementing the screen projection function. The application framework layer provides an application programming interface (API) and a programming framework for the application of the application layer. The application framework layer includes some predefined functions.

[0081] like Figure 3 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

[0082] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0083] Content providers are used to store and retrieve data and make it accessible to applications. The above data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0084] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0085] The phone manager is used to provide the call function of the electronic device 100, such as the management of the call status (including answering, hanging up, etc.).

[0086] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0087] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify that the factory settings are being restored, that a communication connection is being made with a second device, that a download is complete, a message reminder, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.

[0088] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.

[0089] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.

[0090] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0091] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0092] The surface manager is used to manage the display subsystem and provide the fusion of two-dimensional and three-dimensional layers for multiple applications.

[0093] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0094] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0095] A 2D graphics engine is a drawing engine for 2D drawings.

[0096] Exemplarily, when the electronic device 100 is the first electronic device in the above embodiment, the first electronic device can implement the reception of instructions for restoring factory settings, instruction information for completing the formatting operation, notification information for success / failure of file system encryption, downloading and reading of data files, and sending of notification messages, etc.

[0097] Exemplarily, when the electronic device 100 is the second electronic device in the above embodiment, the second electronic device can realize the communication connection status, data transmission information, and sending and receiving of notification messages with the first electronic device.

[0098] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, sensor driver, and the kernel layer corresponds to the kernel module.

[0099] Exemplarily, when the electronic device 100 is the first electronic device in the above embodiment, in the above kernel module, the factory restore flag bit can be set to a first state value, and the factory restore flag bit can be set to a second state value.

[0100] Exemplarily, when the electronic device 100 is the first electronic device in the above embodiment, the first electronic device includes a user space module and a kernel module, and the first electronic device detects that the file system encryption fails. It can be understood that the first electronic device detects the file system encryption failure in the user space module. The first electronic device successfully restarts for the second time. It can be understood that the first electronic device starts the operating system of the first electronic device in the kernel module, and the second restart is successful. The first electronic device sets the factory restore flag to the first state value. It can be understood that the first electronic device sets the factory restore flag to the first state value in the kernel module.

[0101] The present invention provides a method for restoring factory settings. Figure 2 and Figure 3 The first electronic device of the structure shown in FIG. 1 is a first electronic device of the structure shown in FIG. 1 and a second ... Figure 4 As shown, the method may include the following steps S401-S405.

[0102] S401: A first electronic device receives a factory reset instruction from a user, and in response to the factory reset instruction, restarts for the first time.

[0103] For example, taking the first electronic device as a mobile phone, Figure 5As shown, in some embodiments, the user jumps to the second interface by touching the setting application in the first interface. The second interface can be a setting interface, and "restore factory settings" is selected in the setting interface, so that the first electronic device receives the instruction to restore factory settings, and the first electronic device restarts the operating system after shutting down; it should be noted that the above-mentioned "restore factory settings" in the embodiment of the present application can also be "restore to factory", "format mobile phone", "restore factory operation" and other text and / or icon instruction information that instructs the first electronic device to perform a factory reset operation.

[0104] Specifically, the user may also send a command to the first electronic device to restore factory settings by voice control, inputting text commands, and the like. It should be noted that after the first electronic device receives the command to restore factory settings sent by the user, it may display a notification message on the screen indicating that the command has been received, which may be "restoring factory settings", or the first electronic device may not display relevant notification information and directly restart for the first time. Among them, the first restart refers to the first shutdown and then startup of the first electronic device when restoring factory settings. Restarting can be understood as shutting down and then starting up the first electronic device, and can also be understood as restarting the operating system of the first electronic device.

[0105] In an actual application scenario, before or during the process of restoring the factory settings, the first electronic device may not have a communication connection with other devices, or may have one or more communication connections with other devices, such as a serial port, USB, Bluetooth, NFC, or Wi-Fi. Figure 6 As shown, before the factory reset is started, there is already a communication connection between the first electronic device and the second electronic device in the form of a USB connection. And the second electronic device has an application A running in the foreground, and the above application A has the ability to write data to the first electronic device through a communication connection. For example, the application A can be a third-party screen projection software, such as An-link software, etc., which is not limited here. Among them, after the third-party screen projection software detects that the USB interface is connected for communication, it can write data to the first electronic device.

[0106] S402: After the first restart is successful, the first electronic device enters a recovery mode and performs a recovery operation.

[0107] The above-mentioned recovery processing operation may include performing a formatting processing operation to delete data in the user data file in the file system. That is, in the recovery mode, the user data file in the first electronic device may be cleaned up and the preset file in the user space may be formatted.

[0108] In some embodiments, after entering the above recovery mode, the first electronic device may further set a factory restore flag, and set the factory restore flag to a first state value. The factory restore flag is used to indicate whether the first electronic device is in a factory restore state. When the factory restore flag is the first state value, it indicates that the first electronic device is in a factory restore state. For example, the factory restore flag may be FormattingFlag, and the first state value may be 1, that is, FormattingFlag=1.

[0109] In some embodiments, the above S402 may include S402a-S402b:

[0110] S402a: The first electronic device performs a formatting operation to delete data in the user data file in the file system.

[0111] The user data files include preset files, application files installed by the user in the process of using the first electronic device, downloaded file data, etc. It is understandable that the user data files can be stored in a preset storage path. In the recovery mode, the first electronic device can delete the data in the user data files in the file system and format the user data files, etc.

[0112] S402b: After deleting the data in the user data file in the file system, the first electronic device sets the factory restore flag to a first state value.

[0113] The first state value is used to indicate that the first electronic device is in a state of restoring factory settings. For example, the first state value may be 1, or other values ​​such as true, Y, etc., which are not limited here. By detecting that the factory restore flag is the first state value, it is determined that the first electronic device is in a state of restoring factory settings, which provides conditions for subsequent determination of whether the first electronic device is in a special recovery scenario or not, and is conducive to improving the speed and accuracy of restoring the factory settings of the first electronic device.

[0114] In some other embodiments, after entering the recovery mode, there is no order between deleting the data in the user data file and setting the factory restore flag. The factory restore flag may be set first and then the data in the user data file may be deleted, or deleting the user data file and setting the factory restore flag may be performed in parallel, which is not limited in the embodiments of the present application.

[0115] S403: The first electronic device restarts for the second time.

[0116] After executing the recovery process operation, the second electronic device performs a second reboot.

[0117] During the process of restoring factory settings, the process of the first electronic device performing a second restart includes: detecting whether the first electronic device is in a state of restoring factory settings, and performing an encryption operation on the file system. Among them, detecting whether the first electronic device is in a state of restoring factory settings can be achieved by detecting the state value of the factory restore flag, or determining that the first electronic device is in a state of restoring factory settings through notification information, etc., which is not limited here. When the first electronic device restarts for the second time and reaches the native stage of the local framework layer, it can perform an encryption operation on the file system.

[0118] In some embodiments, the process of the first electronic device performing a second restart includes performing a file system encryption operation and detecting the status value of the factory restoration flag. It should be understood that in the embodiments of the present application, performing the file system encryption operation and detecting the status value of the factory restoration flag are not in any particular order. The file system encryption operation may be performed first and then the status value of the factory restoration flag is detected, or the status value of the factory restoration flag may be detected first and then the file system encryption operation may be performed. Alternatively, the file system encryption operation and the detection of the status value of the factory restoration flag may also be performed in parallel.

[0119] In a possible implementation, the first electronic device restarts the operating system after being shut down, detects that the state of the factory restore flag is a first state value, and performs a file system encryption operation.

[0120] In another possible implementation, the first electronic device restarts the operating system after shutting down, performs a file system encryption operation, and after detecting that the file system encryption fails, detects the status value of the factory restore flag.

[0121] S404: During the second restart process, the electronic device detects that the file system encryption fails.

[0122] During the second restart process, the first electronic device detects whether the file system encryption is successful. If the file system encryption is successful, the first electronic device is started normally, and the factory settings of the first electronic device are restored, which is conducive to quickly and conveniently restoring the factory settings of the first electronic device. If the file system encryption fails, it is further determined whether it is a special recovery scenario.

[0123] During the process of restoring factory settings, if there is a communication connection between the first electronic device and the second electronic device, the second electronic device may write data to the first electronic device based on the communication connection, resulting in some directories that should be empty not being empty, such as user data files that are not empty, and user data files include data received from the second electronic device based on the communication connection, which will cause the file system encryption to fail. When the foreground application running on the second electronic device has the ability to write data to the first electronic device based on the communication connection, such as when the foreground application is a screen projection software or a file transfer software, the foreground application is likely to write data to the first electronic device based on the communication connection during the process of restoring factory settings, resulting in some directories that should be empty not being empty, thereby causing the file system encryption to fail.

[0124] S405, the first electronic device detects that the factory settings have been restored, and there is a communication connection between the first electronic device and the second electronic device, and the first electronic device is turned on normally, and the second restart is successful.

[0125] During the second restart, if the preset conditions are met, the first electronic device restarts successfully; if the preset conditions are not met, the first electronic device fails to restart for the second time. Among them, the preset conditions may include: the first electronic device is in a state of restoring factory settings, and there is a communication connection between the first electronic device and the second electronic device. Through the above method, judgment is made based on the preset conditions, which is conducive to improving the efficiency of restoring the factory settings of the first electronic device. Among them, the first electronic device is in a state of restoring factory settings after detecting the user's instruction to restore factory settings until the factory settings are restored. That is, the first electronic device is in a state of restoring factory settings from the time it detects the user's instruction to restore factory settings to the success / failure of the second restart, or is in the process of restoring factory settings.

[0126] The factory reset state can be determined by the factory reset flag. Figure 7As shown, after the first electronic device is shut down, the operating system is restarted to perform the file system encryption operation. If the file system encryption fails, the state value of the factory restore flag and the communication connection state between the first electronic device and the second electronic device are detected. If the state value of the factory restore flag is detected to be the first state value, there is a communication connection between the first electronic device and the second electronic device, the first electronic device skips the non-booting scheme, boots up normally, and the first electronic device completes the factory reset. In this case, during the process of restoring the factory settings of the first electronic device, the file system encryption may fail because the second electronic device wrote data to the first electronic device based on the communication connection between the two. At this time, the first electronic device is in a special recovery scenario, and the first electronic device can complete the factory reset operation, so the first electronic device should boot up normally.

[0127] In some embodiments, after the first electronic device is shut down, the operating system is started again to perform a file system encryption operation. If it is detected that the file system encryption fails, the status value of the factory restore flag and the communication connection status between the first electronic device and the second electronic device are detected. If it is detected that the status value of the factory restore flag is not the first status value, or the first electronic device has no communication connection with the other electronic device, there may be other reasons that cause the file system encryption failure, such as OS_PatchLevel mismatch. At this time, the no-boot solution is processed according to the original fault process, and the result of the file system encryption failure is transmitted to the operating system through the system call IOCTL dedicated to input and output operations, and the first electronic device triggers the no-boot solution.

[0128] In some embodiments, the preset condition includes: the first electronic device is in a state of restoring factory settings, and there is a USB connection between the first electronic device and the second electronic device. In this case, when the file system encryption of the first electronic device fails, if it is detected that the first electronic device is in a state of restoring factory settings and the USB interface is in place (which can be understood as having a communication connection with other devices through the USB interface), the first electronic device skips the non-booting solution, boots normally, and the second restart is successful. Specifically, when the first electronic device is in the process of restoring factory settings, there is a USB connection with the second electronic device, and the second electronic device has the ability to write data to the first electronic device (or has data read and write permissions), the second electronic device will not start up when it is restarted for the second time, so that the first electronic device is in a special recovery scenario. For this special recovery scenario, a factory restore flag is set each time the factory settings are restored to mark that the first electronic device is in the factory restore state, and then in the second restart process, the code is pre-embedded in the place corresponding to the special scenario process processing, and it is identified whether the mobile phone is in the factory restore state before it is turned off and turned on again, and whether the USB is in place. If both conditions are met, the non-startup solution is skipped or the non-startup solution is set to METHOD_OD_NOTING, and a normal startup operation is performed. After the normal startup, the factory restore flag is set to the second state value. Through the above method, the factory restore flag and the USB in place state are judged, which is conducive to clearly judging whether the first electronic device is in a special recovery scenario, and the first electronic device is normally started according to the judgment result to complete the factory restore operation, which is conducive to improving the user experience. When encrypting the file system, if it is detected that the first electronic device is not in the factory reset state or the USB is not in place, the first electronic device will not start up and the second restart will fail.

[0129] In some other embodiments, the preset condition includes: the first electronic device is in a state of restoring factory settings, and there is an NFC connection between the first electronic device and the second electronic device.

[0130] Through the above S401-S405 method, after receiving the user instruction to restore the factory settings, the first electronic device restarts the operating system of the first electronic device for the first time, enters the recovery mode, and restarts the operating system of the first electronic device for the second time. During the second restart, the first electronic device detects the execution result of the file system encryption. If the file system encryption fails, it identifies whether the first electronic device is in the factory setting restoration state (such as whether the factory restoration flag is the first state value) and whether there is a communication connection (such as whether the USB is in place). If the identification result meets the preset conditions, the first electronic device is subjected to special code processing to skip the original non-booting scheme, and is normally booted and started. The first electronic device completes the factory setting restoration this time. Through the above method, it is beneficial to improve the efficiency and convenience of restoring the factory settings of the first electronic device.

[0131] In some embodiments, after the above S405, the following steps may also be included:

[0132] S406: After the second restart is successful, the first electronic device sets the factory restoration flag to a second state value or deletes the factory restoration flag.

[0133] In some embodiments, the second status value is used to indicate that the first electronic device is not in a factory reset state. For example, the second status value may be 0, false, N, etc., which is not limited here.

[0134] In some embodiments, Figure 8 As shown, after the above S403, the following may also be included:

[0135] S407: During the second restart process, the electronic device detects that the file system encryption is successful.

[0136] In some embodiments, if the first electronic device performs a file system encryption operation and detects that the file system encryption is successful, the first electronic device boots up normally and the factory settings are restored.

[0137] S408, the first electronic device is turned on normally, and after the second restart is successful, the factory restoration flag is set to a second state value.

[0138] In some embodiments, the second status value is used to indicate that the first electronic device is not in the factory setting restoration state. The second status value can be used to clearly determine that the first electronic device is not in the factory setting restoration state.

[0139] The method for restoring factory settings in the above embodiment of the present application can be directed to a first electronic device in a special restoration scenario when restoring factory settings, skip the non-boot scheme, and complete the factory settings restoration operation after the operating system is normally started. That is, in the process of restoring factory settings, the first electronic device responds to the instruction issued by the user to instruct the first electronic device to restore factory settings, and performs the first restart. After the first restart is successful, the first electronic device enters the recovery mode, performs the formatting operation, clears the user data, and sets the factory restoration flag to the first state value. Then, the first electronic device restarts for the second time. During the second restart, if the first electronic device detects that the file system encryption fails, when it is determined that the first electronic device is in the state of restoring factory settings, and there is a communication connection between the first electronic device and the second electronic device, the non-boot scheme is skipped, and the boot operation is performed, and the second restart of the first electronic device is successful. Thereby, in the process of restoring factory settings, according to the factory restoration flag and whether there is a communication connection between the first electronic device and the second electronic device, it is determined whether to boot normally, so as to achieve the purpose of the first electronic device completing the factory restoration normally in a special recovery scenario, and improve the user experience.

[0140] In an embodiment of the present application, the timing for establishing a communication connection between the first electronic device and the second electronic device may be before the first electronic device is restored to factory settings, or between the start of restoring factory settings and the first restart, or between the first restart and the second restart, or after the start of the second restart. There may be many specific times and methods for establishing a communication connection between the first electronic device and the second electronic device, which are not limited.

[0141] The present application also provides a first electronic device, see Fig. 9 , the first electronic device includes a user space module 501, a kernel module (kernel) 502 and a boot loader module (bootloader) 503. The first electronic device can detect the success or failure of file system encryption through the user space module, start the operating system of the first electronic device through the kernel module, and set the factory recovery flag bit to the first state value or the second state value through the kernel module.

[0142] Specifically, the user space module 501 is used to receive an instruction from a user to restore the first electronic device to factory settings, for example, to execute step S401 in the aforementioned embodiment.

[0143] The kernel module 502 is used to detect whether the file system encryption is successful or failed, to execute a normal boot operation or a non-boot solution, to transmit the result of the file system encryption failure through a system call IOCTL dedicated to input and output operations when the file system encryption fails, and to set a factory recovery flag after clearing data in recovery mode. For example, steps S404 and S407 in the above-mentioned embodiment are executed.

[0144] Among them, if it is detected that the file system encryption fails, the user space module 501 determines the factory restore flag and the USB in-place status. When the factory restore flag is in the first state value and the USB is in the in-place state, the no-boot solution is skipped or the no-boot solution is set to METHOD_OD_NOTING, and the kernel module (kernel) 502 of the first electronic device performs a normal boot operation.

[0145] Among them, if the file system encryption failure is detected, the user space module 501 determines the factory restore flag and the USB in-place status. If it is not a scenario in which the third-party screen projection software writes data to the first electronic device after factory restore, for example, the file system encryption failure is caused by OS_PatchLevel mismatch, the no-boot solution is executed according to the normal process, and the kernel module (kernel) 502 of the first electronic device performs the no-boot operation.

[0146] The bootloader module 503 is used to start the operating system of the first electronic device, for example, by executing steps S401 and S403 in the above embodiment.

[0147] It is understandable that in order to implement the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to be beyond the scope of the present application.

[0148] In this embodiment, the electronic device can be divided into functional modules according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0149] The present application also provides an electronic device, such as Fig.10 As shown, the electronic device may include one or more processors 1001 , a memory 1002 and a communication interface 1003 .

[0150] The memory 1002 and the communication interface 1003 are coupled to the processor 1001. For example, the memory 1002, the communication interface 1003 and the processor 1001 may be coupled together via a bus 1004.

[0151] The communication interface 1003 is used to transmit data with other devices. The memory 1002 stores computer program code. The computer program code includes computer instructions. When the computer instructions are executed by the processor 1001, the electronic device executes the screen projection method in the embodiment of the present application.

[0152] Among them, the processor 1001 can be a processor or a controller, for example, a central processing unit (CPU), a general processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It can implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the contents of this disclosure. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.

[0153] The bus 1004 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus 1004 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0154] The present application embodiment provides an electronic device, which may include: the above-mentioned communication interface, a memory and one or more processors. The communication interface can provide a wired communication connection function. The communication interface, the memory and the processor are coupled. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device can execute the various functions or steps executed by the mobile phone in the above-mentioned method embodiment. The structure of the electronic device can refer to Figure 2 The structure of the electronic device 100 is shown.

[0155] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes each function or step executed by the mobile phone in the above method embodiment.

[0156] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute each function or step executed by the mobile phone in the above method embodiment.

[0157] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

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

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

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

[0161] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0162] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A method for restoring factory settings, characterized in that: Applied to a first electronic device, the method includes: In response to a first operation, performing a first restart; the first operation is used to instruct the first electronic device to restore factory settings; After the first restart is successful, entering the recovery mode and performing the recovery processing operation; Perform a second reboot; During the second restart process, if it is detected that the file system encryption fails, if the preset conditions are met, the non-booting solution is skipped to perform the booting operation, and the second restart is successful; wherein the preset conditions include: determining that the first electronic device is in a state of restoring factory settings, and detecting that there is a communication connection between the first electronic device and the second electronic device.

2. The method according to claim 1, characterized in that: In the preset condition, the communication connection between the first electronic device and the second electronic device is a universal serial bus (USB) communication connection.

3. The method according to claim 2, characterized in that After entering the recovery mode, the method further includes: Setting the factory reset flag bit to a first state value, where the first state value is used to indicate that the first electronic device is in a state of restoring factory settings; The determining that the first electronic device is in a state of restoring factory settings includes: It is detected that the factory restore flag is the first state value.

4. The method according to claim 3, characterized in that The performing of the recovery processing operation includes: Perform formatting operations to delete data in user data files in the file system; Setting the factory restore flag bit to the first state value includes: After deleting the data in the user data file in the file system, setting the factory restore flag to the first state value.

5. The method according to claim 3 or 4, characterized in that: The method further comprises: After the second restart is successful, the factory restore flag is set to a second state value.

6. The method according to claim 5, characterized in that The method further comprises: If it is detected that the file system encryption fails, and the preset condition is not met, the second restart fails.

7. The method according to claim 6, characterized in that The second restart fails with: The no-boot solution is executed, and the second restart fails.

8. The method according to claim 7, characterized in that The foreground application running on the second electronic device has the ability to write data to the first electronic device through the communication connection.

9. The method according to claim 8, characterized in that During the second restart, file system encryption failures were detected, including: During the second restart, it is detected that the user data file in the file system is not empty, and the encryption of the file system fails.

10. The method according to claim 9, characterized in that During the second reboot, the user data file includes data received from the second electronic device based on the communication connection.

11. The method according to claim 10, characterized in that The method further comprises: If it is detected that the file system encryption is successful, the second restart is successful.

12. The method according to claim 11, characterized in that The first electronic device includes a user space module and a kernel module, and the detecting that the file system encryption fails includes: Detecting, by the user space module, that the file system encryption fails; The second restart was successful, including: Starting the operating system of the first electronic device through the kernel module, and the second restart is successful; The step of setting the factory restore flag bit to a first state value includes: The factory restore flag is set to a first state value through the kernel module.

13. An electronic device, characterized in that: include: A memory and one or more processors; the memory is coupled to the processor; wherein the memory stores computer program code, the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the method as described in any one of claims 1-12.

14. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed on an electronic device, cause the electronic device to execute the method as claimed in any one of claims 1 to 12.

15. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to execute the method according to any one of claims 1 to 12.