Factory setting recovery method and device, electronic equipment and storage medium
By recording the marking serial numbers and factory mapping tables when the electronic equipment is factory-departed, and erasing and replacing data blocks when needed, the problem of factory-departed recovery taking up large storage space is solved, and storage space saving and recovery speed are improved.
Patent Information
- Application Number
- CN202411577570.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-25
AI Technical Summary
When existing electronic devices are shipped out of the factory, in order to restore the factory settings, they need to occupy a large storage space to store the factory system separately.
When the electronic equipment leaves the factory, the factory system is written to the storage device, and the last written data block sequence number is recorded as the mark sequence number, and the current mapping table is saved as the factory mapping table. When receiving the factory reset instruction, the data block with the serial number greater than the serial number is erased according to the marked serial number and the factory mapping table, and replace the current mapping table with the factory mapping table.
Save storage space because only mapping tables need not be saved without additional storage of factory systems, and the factory reset is faster, allowing users to erase data completely and prevent data leakage.
Smart Images

Figure CN119512634A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of storage devices, and in particular to a factory settings recovery method, device, electronic device and storage medium. Background Art
[0002] Nowadays, users can install software and customize configurations on electronic devices such as laptops and mobile phones after they leave the factory. In order to prevent user data from being leaked due to misoperation or user transfer, a factory reset function is generally designed. When the device leaves the factory, a space is allocated on the hard disk or other storage device to store data for restoring the factory defaults. Usually, the device will store a separate copy of the entire factory system, which takes up a relatively large storage space. Summary of the invention
[0003] In view of this, an object of the embodiments of the present invention is to provide a factory settings recovery method, device, electronic device and storage medium to at least partially improve the above-mentioned problem.
[0004] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:
[0005] In a first aspect, an embodiment of the present invention provides a factory settings restoration method, which is applied to an electronic device, and the method includes:
[0006] Writing a factory system into a storage device, wherein the factory system represents the initial content required for the operation of the electronic device; the storage device includes a mapping table and a plurality of data blocks, wherein the data blocks are used to store data, and the mapping table is used to store a mapping relationship between a logic block of the electronic device and the data blocks;
[0007] When the factory system completes writing, the serial number of the data block last written by the factory system to the storage device is recorded as the marked serial number, and the current mapping table is recorded as the factory mapping table, and the factory mapping table is saved to the reserved space of the storage device; the serial number is generated when data is written into an empty data block of the storage device;
[0008] When the factory reset instruction is received, the electronic device is restored to factory settings according to the tag serial number and the factory mapping table.
[0009] Optionally, the method further comprises a step of generating the serial number, comprising:
[0010] receiving a data writing instruction and generating a target logic block on the electronic device;
[0011] Searching the mapping table for a mapping relationship of the target logic block;
[0012] If not, randomly selecting a data block of the storage device as a target data block, and generating a mapping relationship between the target logic block and the target data block;
[0013] Determine whether the target data block has a sequence number;
[0014] If not, the maximum sequence number of each data block plus a preset value is used as the sequence number of the target data block.
[0015] Optionally, restoring the electronic device to factory settings according to the marked serial number and the factory mapping table includes:
[0016] Erasing data blocks of the storage device having a sequence number greater than the marked sequence number;
[0017] The current mapping table of the storage device is replaced with the factory mapping table.
[0018] Optionally, erasing the data block of the storage device having a sequence number greater than the marked sequence number includes:
[0019] Erasing the to-be-erased data blocks of the storage device whose serial numbers are greater than the marked serial numbers by means of fast erasure;
[0020] Erasing the data block to be erased by deep erasing;
[0021] Verify whether the data block to be erased reaches a preset state, and if not, re-execute deep erase.
[0022] Optionally, the step of saving the factory mapping table to a reserved space of the storage device includes:
[0023] Copying the factory mapping table at least once to obtain at least one backup mapping table;
[0024] The factory mapping table and each of the backup mapping tables are saved in the reserved space of the storage device.
[0025] Optionally, after replacing the current mapping table of the storage device with the factory mapping table, the method further includes:
[0026] Verifying whether the factory mapping table correctly reflects the physical locations of all data blocks;
[0027] If not, use any of the backup mapping tables to replace the current mapping table of the storage device.
[0028] Optionally, after receiving the factory reset instruction, the method further includes:
[0029] Verify whether the sender of the factory reset instruction has the authority to restore the factory settings;
[0030] If yes, restoring the electronic device to factory settings;
[0031] If not, stop the operation.
[0032] Optionally, before restoring the electronic device to factory settings according to the marked serial number and the factory mapping table, the method further includes:
[0033] The electronic device is restored to factory settings in a simulated manner according to the marked serial number and the factory mapping table.
[0034] In a second aspect, an embodiment of the present invention provides a factory settings recovery device, which is applied to an electronic device, and the device includes:
[0035] A factory system writing unit, used to write the factory system into a storage device, wherein the factory system represents the initial content required for the operation of the electronic device; the storage device includes a mapping table and a plurality of data blocks, wherein the data blocks are used to store data, and the mapping table is used to store the mapping relationship between the logic blocks of the electronic device and the data blocks;
[0036] a completion point recording unit, used for recording, when the factory system completes writing, the sequence number of the data block last written by the factory system to the storage device as a marked sequence number, recording the current mapping table as a factory mapping table, and saving the factory mapping table to the reserved space of the storage device; the sequence number is generated when data is written into an empty data block of the storage device;
[0037] The factory setting restoring unit is used to restore the factory setting of the electronic device according to the marking serial number and the factory mapping table when receiving the factory setting restoring instruction.
[0038] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-described methods when executing the program.
[0039] The embodiment of the present invention provides a factory settings recovery method, device, electronic device and storage medium. When the electronic device leaves the factory, the factory system is written into the storage device. When the factory system is completely written into the storage device, the serial number of the data block of the factory system last written into the storage device is recorded as the mark serial number, and the current mapping table is recorded as the factory mapping table. The factory mapping table is saved to the reserved space of the storage device. When the factory settings recovery instruction is received, the data blocks of the storage device with a serial number greater than the mark serial number are erased, and the current mapping table of the storage device is replaced with the factory mapping table, so that the factory settings can be restored. Therefore, there is no need to store the factory system separately, only the corresponding mapping table needs to be saved, thereby saving storage space and improving the speed of restoring the factory settings.
[0040] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0042] Figure 1 A schematic structural block diagram of an electronic device provided by an embodiment of the present invention;
[0043] Figure 2 A schematic diagram of a process of restoring factory settings provided by an embodiment of the present invention;
[0044] Figure 3 Another schematic diagram of a method for restoring factory settings provided by an embodiment of the present invention;
[0045] Figure 4 A schematic structural block diagram of a factory settings recovery device provided by an embodiment of the present invention.
[0046] Icons: 100 - electronic device; 101 - memory; 102 - communication interface; 103 - processor; 104 - bus; 300 - factory settings recovery device; 310 - factory system writing unit; 320 - completion point recording unit; 330 - factory settings recovery unit. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0048] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0050] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0051] In the prior art, users of electronic devices such as laptops and mobile phones can install software and perform custom configuration operations after leaving the factory. In order to prevent the leakage of user data in the event of misoperation or user transfer, a factory reset function is generally designed. When leaving the factory, a storage device such as a hard disk is allocated with a space to store data for restoring the factory defaults. Usually, the device will store a separate copy of the entire factory system, which takes up a relatively large storage space.
[0052] Based on the above situation, an embodiment of the present invention provides a factory settings recovery method, device, electronic device and storage medium. When the electronic device leaves the factory, the factory system is written into the storage device. When the entire factory system is written into the storage device, the serial number of the data block last written into the storage device by the factory system is recorded as the mark serial number, and the current mapping table is recorded as the factory mapping table. The factory mapping table is saved to the reserved space of the storage device, so that only the corresponding mapping table needs to be saved, and there is no need to store the factory system separately, thereby saving storage space.
[0053] To implement the process steps and functions of each example of the present invention, please refer to Figure 1 , Figure 1 A schematic structural block diagram of an electronic device provided by an embodiment of the present invention. The electronic device 100 includes a memory 101 and a processor 103, and the memory 101 and the processor 103 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses 104 or signal lines. The memory 101 can be used to store software programs and modules, and the processor 103 executes the software programs and modules stored in the memory 101 to perform various functional applications and data processing.
[0054] The electronic device 100 may be, but is not limited to, a personal computer (PC), a server, a distributed computer, etc. It is understandable that the electronic device 100 is not limited to a physical server, but may also be a virtual machine on a physical server, a virtual machine built on a cloud platform, etc., which can provide the same functions as the server or virtual machine. The operating system of the electronic device 100 may be, but is not limited to, a Windows system, a Linux system, etc.
[0055] Among them, the memory 101 can be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc.
[0056] The communication connection between the electronic device 100 and an external device is achieved through at least one communication interface 102 (which can be wired or wireless).
[0057] The processor 103 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the embodiment of the present invention can be completed by the hardware integrated logic circuit in the processor 103 or the instructions in the form of software. The processor 103 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0058] Understandably, Figure 1 The structure shown is for illustration only. The electronic device 100 may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0059] The following is an exemplary description of the factory settings restoration method provided by the present invention. Specifically, Figure 2 A flowchart of a factory settings restoration method provided by an embodiment of the present invention is shown in FIG. Figure 2 The method is applied to a controller of an electronic device, wherein the electronic device further comprises a storage device connected to the controller for communication, and the controller can be the above-mentioned Figure 1 The electronic device 100 shown in FIG. 1 includes: Figure 2 The following steps are shown:
[0060] S210: Writing the factory system into a storage device, wherein the factory system represents the initial content required for the operation of the electronic device; the storage device includes a mapping table and multiple data blocks, the data blocks are used to store data, and the mapping table is used to store the mapping relationship between the logic blocks of the electronic device and the data blocks.
[0061] Electronic devices can be mobile phones, tablets, computers, etc., which are pre-installed with a factory system when leaving the factory. The factory system generally includes an operating system, pre-installed applications, drivers, etc. The factory system needs to be stored in the storage device of the electronic device to enable the user to operate the electronic device normally when using it for the first time.
[0062] The storage device includes a mapping table, which is used to store the mapping relationship between the logic blocks and the data blocks of the electronic device. As the data is written into the storage device, the mapping table will change.
[0063] S220: When the factory system write is completed, the serial number of the data block last written by the factory system to the storage device is recorded as the marked serial number, and the current mapping table is recorded as the factory mapping table, and the factory mapping table is saved to the reserved space of the storage device. The serial number is generated when data is written into an empty data block of the storage device.
[0064] The storage device is based on Nand, which has the special physical property that the data blocks cannot be randomly overwritten. However, our system usually writes data randomly. Therefore, when writing data, a logical-to-physical mapping is performed, and the actual stored data blocks are mapped through a mapping table. For example, the logical 4-Byte content of the storage device will be mapped to the physical 4k Byte content, represented by a 4-Byte mapping table. In this way, the ratio between the mapping table and the actual stored data is 1:1000. For some products, this table will be smaller. During the data writing process, the storage device will assign a unique serial number to the currently written data block. When writing the next data block, it will assign an incremental serial number to the next data block, which will be updated each time a new data block is written.
[0065] When the factory system is written, the serial number of the data block of the last write operation is recorded as the marking serial number. This serial number is used to identify the data block that needs to be erased when restoring the factory settings. Correspondingly, when the factory system is written, the storage device will also have a mapping table, which is the current mapping table. The current mapping table is recorded as the factory mapping table and saved to the reserved space of the storage device.
[0066] S230: When a factory reset instruction is received, the electronic device is restored to factory settings according to the tag serial number and the factory mapping table.
[0067] In order to ensure that user data is not leaked in the case of misoperation or user transfer, the user generally needs to restore the factory settings. Therefore, when the factory settings need to be restored, the factory settings of the electronic device can be restored according to the marked serial number and the factory mapping table.
[0068] This method saves only the serial number and mapping table of the data block when the factory system completes writing. When the factory settings need to be restored, the serial number and mapping table are used to restore the factory settings. Since the mapping table is generally less than 1:1000, that is, we only need to save 1KB of the mapping table for 1GB of data. Therefore, it will not take up too much extra backup space to save the data required for factory restoration.
[0069] Optionally, the method further comprises a step of generating a serial number, comprising:
[0070] Receive data write instructions and generate target logic blocks on electronic devices.
[0071] Check whether the mapping table has a mapping relationship of the target logical block.
[0072] If not, a data block of the storage device is randomly selected as the target data block, and a mapping relationship between the target logic block and the target data block is generated.
[0073] Determine whether the target data block has a sequence number.
[0074] If not, the maximum sequence number among the data blocks plus the preset value is used as the sequence number of the target data block.
[0075] When an electronic device receives a data write instruction, it can generate a target logic block on the operating system memory or file system of the electronic device to identify the location of the data on the storage device. First, check whether there is a mapping relationship of the target logic block on the mapping table of the storage device. If not, randomly select a data block of the storage device as the target data block, and generate a mapping relationship between the target logic block and the target data block, and determine whether the target data block has a sequence number. If the target data block does not have a sequence number, add the largest sequence number of each data block in the storage device to a preset value as the sequence number of the target data block. For example, the preset value is 1, and the largest sequence number among the data blocks is 100, then 101 is used as the sequence number of the target data block.
[0076] In a possible implementation, in order to quickly complete the factory reset, see Figure 3 , Figure 3 Another flowchart of a factory settings restoration method provided by an embodiment of the present invention, the above step S230 may include the following: Figure 3 The following steps are shown:
[0077] S231: Erasing the data blocks of the storage device whose serial numbers are greater than the marked serial numbers.
[0078] S232: Replace the current mapping table of the storage device with the factory mapping table.
[0079] When restoring the factory settings, the data blocks to be erased are found according to the marked serial number and are directly erased. At this time, the data in the storage device is only the data when the electronic device leaves the factory. For example, when the electronic device leaves the factory, the recorded marked serial number is 10. When erasing the data on the storage device, the data of the data blocks with serial numbers 0 to 10 are retained, and the data of the data blocks with serial numbers greater than 10 are erased.
[0080] However, the mapping relationship data in the mapping table is now incorrect, so the current mapping table can be replaced with the pre-saved factory mapping table to restore the factory settings of the electronic device.
[0081] In the subsequent operation of the storage device, the data in the physical space before the recorded mark serial number will not be modified or erased. When it is necessary to restore the factory settings, we only need to erase all the data after the recorded mark serial number, and then restore the mapping table to the factory saved, so as to achieve the purpose of restoring the factory settings.
[0082] This method is faster than the traditional method of restoring from a backup area, and can completely erase the data of subsequent users, ensuring that non-factory data is completely removed from the physical storage medium, thereby ensuring that user data will not be leaked.
[0083] In the case of electronic device user transfer, for example, the user sells a mobile phone that has been used for a period of time. At this time, the user needs to restore the phone to factory settings. In this case, the user hopes to clean up the used data more thoroughly. Optionally, the above step S231 may include the following steps:
[0084] S2311: Erasing the to-be-erased data blocks of the storage device whose serial numbers are greater than the marked serial numbers by means of quick erasure.
[0085] The first stage is to erase the data blocks to be erased by fast erasing, which can be done using the built-in erase command of the storage device. The purpose of fast erasing is to set all storage cells to a known state so that subsequent erasures are faster.
[0086] S2312: Erasing the data block to be erased by deep erasing.
[0087] The second stage is to erase the data blocks to be erased through deep erasure, which is a more thorough process than quick erasure and involves more complex voltage operations or the use of special erasure technology. The purpose of deep erasure is to ensure that the data is completely cleared and cannot be recovered by existing data recovery technology.
[0088] S2313: Verify whether the data block to be erased has reached a preset state, if not, re-execute deep erase.
[0089] After the deep erase is completed, the erased data block to be erased is re-read to verify whether it is completely erased. If not, the deep erase is re-executed to enable it to be completely erased.
[0090] In order to ensure that the electronic device can still be restored to factory settings when the original factory mapping table becomes unavailable due to any reason (such as hardware failure, data corruption, etc.), the factory mapping table can be backed up. Optionally, the step of saving the factory mapping table to the reserved space of the storage device may include:
[0091] S221: Copy at least one factory mapping table to obtain at least one backup mapping table.
[0092] S222: Save the factory mapping table and each backup mapping table to the reserved space of the storage device.
[0093] By copying the factory mapping table into multiple mapping tables and saving them to the reserved space of the storage device, when data in one factory mapping table is damaged, the other backup mapping tables can be used to restore the electronic device to factory settings. Therefore, after replacing the current mapping table of the storage device with the factory mapping table, the following may also be included:
[0094] Verify that the factory mapping table correctly reflects the physical location of all data blocks.
[0095] If not, any backup mapping table is used to replace the current mapping table of the storage device.
[0096] After replacing the current mapping table of the storage device with the factory mapping table, verify whether the real data of the data block can be read normally using the mapping table. If the read data is normal, the factory settings can be restored. If the read data is abnormal, use any backup mapping table to replace the current mapping table of the storage device, and then verify until the read data is normal.
[0097] In order to protect the user's data security, not everyone can restore the factory settings of the electronic device. When restoring the factory settings, the user needs to be authenticated. After receiving the factory settings restore instruction, it can also include:
[0098] Verify whether the sender of the factory reset command has the authority to restore the factory settings.
[0099] If so, perform a factory reset on the electronic device.
[0100] If not, stop the operation.
[0101] After receiving the factory reset instruction, the sender of the factory reset instruction is first verified, which may include verifying that the user has passed the identity authentication, checking the permission level of the user account, ensuring that the user has the permission to perform the factory reset operation, etc. If the verification is passed, the electronic device is restored to factory settings. If the verification is not passed, the factory reset operation request is rejected.
[0102] Furthermore, since the factory mapping table may be damaged, in order to avoid errors in the process of restoring the factory settings, optionally, before restoring the factory settings of the electronic device, the electronic device may be simulated to restore the factory settings according to the marked serial number and the factory mapping table. By simulating the factory restoration, it can be known whether the factory restoration can be completed using the marked serial number and the factory mapping table. And then whether the factory restoration can be completed using the factory mapping table.
[0103] Further, based on the implementation of the above-mentioned factory settings restoration method, the embodiment of the present invention also provides a factory settings restoration device, referring to Figure 4 , Figure 4 A schematic structural block diagram of a factory setting restoration device provided in an embodiment of the present invention, wherein the factory setting restoration device 300 is applied to an electronic device, and the factory setting restoration device includes:
[0104] The factory system writing unit 310 is used to write the factory system into the storage device, where the factory system represents the initial content required for the operation of the electronic device; the storage device includes a mapping table and multiple data blocks, where the data blocks are used to store data, and the mapping table is used to store the mapping relationship between the logic blocks and data blocks of the electronic device.
[0105] The completion point recording unit 320 is used to record the serial number of the data block last written by the factory system to the storage device as the mark serial number when the factory system writes to the storage device, and record the current mapping table as the factory mapping table, and save the factory mapping table to the reserved space of the storage device; the serial number is generated when the data is written to the empty data block of the storage device.
[0106] The factory setting restoring unit 330 is used to restore the factory settings of the electronic device according to the tag serial number and the factory mapping table when receiving the factory setting restoring instruction.
[0107] In summary, the embodiments of the present invention provide a method, device, electronic device and storage medium for restoring factory settings. When the electronic device leaves the factory, the factory system is written into the storage device. When the factory system is completely written into the storage device, the serial number of the data block that the factory system last wrote into the storage device is recorded as the mark serial number, and the current mapping table is recorded as the factory mapping table. The factory mapping table is saved to the reserved space of the storage device. When the factory setting restoration instruction is received, the data block of the storage device with a serial number greater than the mark serial number is erased, and the current mapping table of the storage device is replaced with the factory mapping table, and the factory setting restoration can be completed. Therefore, there is no need to store the factory system separately, only the corresponding mapping table needs to be saved, thereby saving storage space, and it is faster than the traditional copy and restore from the backup area. The data of subsequent users can be completely erased once, and the non-factory data can be completely removed from the physical storage medium, thereby ensuring that the user's data will not be leaked.
[0108] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a module, a program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0109] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0110] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a computer-readable storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0111] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
[0112] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
Claims
1. A factory setting recovery method, characterized in that: Applied to electronic equipment, the method comprises: Writing a factory system into a storage device, wherein the factory system represents the initial content required for the operation of the electronic device; the storage device includes a mapping table and a plurality of data blocks, wherein the data blocks are used to store data, and the mapping table is used to store a mapping relationship between a logic block of the electronic device and the data blocks; When the factory system completes writing, the serial number of the data block last written by the factory system to the storage device is recorded as the marked serial number, and the current mapping table is recorded as the factory mapping table, and the factory mapping table is saved to the reserved space of the storage device; the serial number is generated when data is written into an empty data block of the storage device; When the factory reset instruction is received, the electronic device is restored to factory settings according to the tag serial number and the factory mapping table.
2. The method according to claim 1, characterized in that The method further comprises a step of generating the serial number, comprising: receiving a data writing instruction and generating a target logic block on the electronic device; Searching the mapping table for a mapping relationship of the target logic block; If not, randomly selecting a data block of the storage device as a target data block, and generating a mapping relationship between the target logic block and the target data block; Determine whether the target data block has a sequence number; If not, the maximum sequence number of each data block plus a preset value is used as the sequence number of the target data block.
3. The method according to claim 1, characterized in that The step of restoring the electronic device to factory settings according to the marked serial number and the factory mapping table includes: Erasing data blocks of the storage device having a sequence number greater than the marked sequence number; The current mapping table of the storage device is replaced with the factory mapping table.
4. The method according to claim 3, characterized in that Erasing the data block of the storage device having a sequence number greater than the marked sequence number includes: Erasing the to-be-erased data blocks of the storage device whose serial numbers are greater than the marked serial numbers by means of fast erasure; Erasing the data block to be erased by deep erasing; Verify whether the data block to be erased reaches a preset state, and if not, re-execute deep erase.
5. The method according to claim 3, characterized in that: The step of saving the factory mapping table to the reserved space of the storage device includes: Copying the factory mapping table at least once to obtain at least one backup mapping table; The factory mapping table and each of the backup mapping tables are saved in the reserved space of the storage device.
6. The method according to claim 5, characterized in that After replacing the current mapping table of the storage device with the factory mapping table, the method further includes: Verifying whether the factory mapping table correctly reflects the physical locations of all data blocks; If not, use any of the backup mapping tables to replace the current mapping table of the storage device.
7. The method according to claim 1, characterized in that After receiving the factory reset instruction, the method further includes: Verify whether the sender of the factory reset instruction has the authority to restore the factory settings; If yes, restoring the electronic device to factory settings; If not, stop the operation.
8. The method according to claim 1, characterized in that Before restoring the electronic device to factory settings according to the marked serial number and the factory mapping table, the method further includes: The electronic device is restored to factory settings in a simulated manner according to the marked serial number and the factory mapping table.
9. A factory settings recovery device, characterized in that: Applied to electronic equipment, the device comprises: A factory system writing unit, used to write the factory system into a storage device, wherein the factory system represents the initial content required for the operation of the electronic device; the storage device includes a mapping table and a plurality of data blocks, wherein the data blocks are used to store data, and the mapping table is used to store the mapping relationship between the logic blocks of the electronic device and the data blocks; a completion point recording unit, used for recording, when the factory system completes writing, the sequence number of the data block last written by the factory system to the storage device as a marked sequence number, recording the current mapping table as a factory mapping table, and saving the factory mapping table to the reserved space of the storage device; the sequence number is generated when data is written into an empty data block of the storage device; The factory setting restoring unit is used to restore the factory setting of the electronic device according to the marking serial number and the factory mapping table when receiving the factory setting restoring instruction.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.