Method for restoring factory settings and related equipment
By creating a backup partition within the user partition and backing up system data, the issues of device overheating and lag after a factory reset were resolved, thus improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2026-04-10
AI Technical Summary
After electronic devices are restored to factory settings, problems such as severe overheating and lag often occur, affecting the user experience.
Create a backup partition within the user partition, back up system data in advance, and restore the data to the user partition after a factory reset to avoid data loss affecting system functionality.
It improves data recovery efficiency, reduces device overheating and network lag, and enhances user experience.
Smart Images

Figure CN121833340A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of electronic devices, and particularly relates to a method for restoring factory settings and related devices. BACKGROUND
[0002] At present, the use rate of electronic devices is higher and higher, and an operating system is usually installed on the electronic device. The operating system is a software system for controlling and managing hardware and software resources of the electronic device, and the electronic device needs to install the operating system before being used by a user. For example, when the electronic device is a mobile phone, the corresponding operating system (such as an IOS operating system, an Android operating system, etc.) needs to be installed on the mobile phone before various application programs can be used.
[0003] In the process of using the electronic device, the user may execute the operation of restoring factory settings on the operating system. For example, when the user encounters the situation of operating system lag or insufficient storage space, or the user considers privacy protection before reselling the electronic device, the user may execute the operation of restoring factory settings on the electronic device to clear the user data stored on the electronic device.
[0004] However, in actual application scenarios, after the user executes the operation of restoring factory settings on the electronic device and reboots the electronic device, the user may find that the use experience of the electronic device is not good for a period of time, such as the situation of serious heating of the electronic device, or the situation of operating system lag or network lag. SUMMARY
[0005] The embodiments of the present application provide a method for restoring factory settings and related devices, which can reduce the situations of device heating, running lag, etc. after the electronic device completes the operation of restoring factory settings, and improve the use experience of the user.
[0006] In a first aspect, a method for restoring factory settings is provided, the method is applied to an electronic device, the electronic device includes a memory, the memory includes a user partition, and the method includes: in response to triggering the electronic device to execute the operation of restoring factory settings, splitting a backup partition from the user partition; reading first system data from the user partition and writing the first system data into the backup partition, and then executing the operation of restoring factory settings; after completing the operation of restoring factory settings, reading the first system data from the backup partition and re-writing the first system data into the user partition.
[0007] By the scheme, the first system data can be backed up in advance before the electronic device performs the factory reset, in which case, even if the factory reset formats the data in the user partition, the first system data can be restored to the user partition as soon as possible after the factory reset is completed. By the scheme, it can be avoided that the electronic device is affected by the absence of the first system data after the factory reset is completed, resulting in that part of the system function (such as AI function) is affected, or the fluency of the system or software is affected. On the other hand, the scheme can improve the efficiency of data recovery, and at the same time can avoid some problems caused by regenerating the first system data, such as serious device heating, network lag, system lag, etc.
[0008] In the above scheme, a part of the space in the user partition is divided as a backup partition for temporarily storing the first system data. During the process of performing the factory reset, the electronic device selects the original user partition to perform the process of the factory reset, so that the data in the backup partition can be preserved during the process of the factory reset, and at the same time, the normal progress of the factory reset process is not affected.
[0009] In a possible implementation manner of the first aspect, the backup partition is divided from the user partition, including: dividing a backup partition of a preset size from a tail of the user partition.
[0010] In one aspect, the backup partition is divided from the tail of the user partition. The reason for dividing the space from the tail of the user partition is that the scheme wants to avoid damaging the first system data as much as possible when dividing the space, because if the first system data is damaged, even if the data is backed up, the data cannot be normally used after the electronic device is started up. The data in the user partition is usually stored from front to back, so the probability of the tail space being empty is relatively large, so dividing the space from the tail of the user partition can avoid damaging the first system data as much as possible.
[0011] On the other hand, the backup space of the preset size is divided. The preset size can be a preconfigured value, or a value determined by the electronic device according to the first system data. Therefore, by the scheme, the size of the backup space can be flexibly determined, which can meet the needs of data backup, and can avoid space waste, or reduce the situation that the first system data in the original user partition is damaged.
[0012] In a possible implementation manner of the first aspect, the backup partition is divided from the user partition, including: in a case where the size of the first system data is greater than or equal to a preset threshold, dividing the backup partition from the user partition.
[0013] Exemplarily, if the to-be-backed-up data (i.e., the first system data) is relatively large (e.g., more than 3G), the first system data can be backed up by using the scheme provided in the embodiments of the present application, i.e., a backup partition is split from the user partition to back up the first system data, so that a large amount of data can also be backed up.
[0014] Correspondingly, if the to-be-backed-up data (i.e., the first system data) is relatively small (e.g., less than 3G), the first system data can be backed up by using the free partition in the system partition, which can avoid the operation of splitting the space and improve the stability of the data.
[0015] In a possible implementation of the first aspect, before the backup partition is split from the user partition, the method further includes: calculating a hash value according to the first system data in the user partition, and storing the hash value into a first sub-partition of the system partition of the memory, the first sub-partition being a free partition in the system partition in a process of performing the recovery factory setting; after the backup partition is split from the user partition, the method further includes: verifying the integrity of the first system data in the user partition by using the hash value; and determining that the integrity verification of the first system data is passed.
[0016] It should be understood that the scheme is executed only when the integrity verification of the first system data is passed, because the first system data in the original user partition can be damaged when the space is split, and the hash value is originally used to verify the integrity of the first system data, so the hash value must be calculated under the condition that the first system data is complete.
[0017] In a possible implementation of the first aspect, after the first system data is written into the user partition again, the method further includes: verifying the integrity of the first system data in the user partition by using the hash value; and formatting the user partition in a case that the verification fails.
[0018] In the above scheme, after the first system data is written into the user partition again, the integrity of the first system data can be verified. If the verification fails, it means that the first system data can be damaged and the data is unusable, so the user partition can be formatted to reduce the occupation of the space by invalid data.
[0019] In a possible implementation of the first aspect, after the first system data is written into the user partition again, the method further includes: merging the backup partition into the user partition.
[0020] Through the above scheme, the backup partition can be merged back into the user partition after the backup partition is used up, i.e., the user partition is restored to the original state, which can avoid the decrease of the user space available to the user due to the execution of the scheme.
[0021] In a possible implementation manner of the first aspect, before merging the backup partition into the user partition, the method further includes: formatting the backup partition.
[0022] In the above scheme, the integrity of the backup data (i.e., the first system data) can be verified by the hash value after the backup data is restored to the user partition. If the integrity verification of the data fails, the data should be discarded (i.e., the user partition is cleared again), so as to avoid the case that the subsequent system runs incorrectly due to incomplete data.
[0023] In a possible implementation manner of the first aspect, the first system data includes model data and / or optimization data.
[0024] For the case that the first system data includes model data: if the electronic device downloads the model data from the cloud after completing the factory reset, the network of the electronic device may be occupied, which may cause network lag, and may also cause the power consumption of the electronic device to increase. According to the scheme provided in the present application, the model data can be directly restored from the backup partition (i.e., the backup partition) to the user partition after completing the factory reset, so as to avoid the network occupation.
[0025] For the case that the first system data includes optimization data: if the electronic device recompiles the optimization data by using a local compiler after completing the factory reset, the power consumption of the device may increase, and the device may heat seriously, thereby affecting the system fluency. According to the scheme provided in the present application, the optimization data can be directly restored from the backup partition (i.e., the backup partition) to the user partition after completing the factory reset, so as to reduce the power consumption and heating of the device.
[0026] In a possible implementation manner of the first aspect, the system partition includes a first static partition and a second static partition, and the operating system of the electronic device currently runs in the first static partition. The first sub-partition includes one or more of the following sub-partitions: a plurality of sub-partitions in the second static partition, and an extended memory swap area in the system partition.
[0027] In the above scheme, any one or more sub-partitions in the second static partition can be used to store the hash value (i.e., as the first sub-partition), wherein the second static partition is a non-running partition, i.e., the current system runs in the first static partition, and the second static partition is used to backup the data in the first static partition. Therefore, the second static partition does not participate in the factory reset process, and therefore the sub-partitions in the second static partition can be used to store the hash value.
[0028] In the above scheme, the extended memory swap area can also store the hash value (i.e., as the first sub-partition). The extended memory swap area is used to support the "smart memory operation" function. Therefore, even if the extended memory swap area is used to store the hash value, at most, the system running space is temporarily reduced, which does not affect the operation of the system. Compared with the benefits obtained by the scheme of the present application, the impact of the reduced running space can be ignored.
[0029] In a possible implementation of the first aspect, in the case where the backup partition includes the extended memory swap area, before the first system data is written to the backup partition, the method further includes: turning off the first function, the first function being used to set the extended memory swap area as the running memory of the electronic device.
[0030] In the above scheme, if the extended memory swap area is to be used to store the hash value, the first function (i.e., the "smart memory operation" function) can be temporarily turned off, so that the hash value is not overwritten by other newly written data when the hash value is stored in the extended memory swap area.
[0031] In a possible implementation of the first aspect, before the backup partition is split from the user partition, the method further includes: determining that the data in the corresponding sub-partitions in the first static partition and the second static partition are consistent; and / or, determining that the electronic device is not currently in a system upgrade process.
[0032] In the above scheme, if a sub-partition in the second static partition is to be used to store the hash value, the second static partition can be detected before the user partition is spatially split. The detection can be whether the data in the corresponding sub-partitions in the first static partition and the second static partition are consistent, or whether the current system is being upgraded. Only when it is determined that the second static partition is not currently in use, the sub-partition in the second static partition is used to store the hash value, so that the situation that the system fails due to data conflict can be prevented.
[0033] In a possible implementation of the first aspect, in the case where the first sub-partition includes a second sub-partition in the second static partition, after the first system data is re-written to the user partition, the method further includes: copying the data in a third sub-partition to the second sub-partition, the third sub-partition belonging to the first static partition, and the third sub-partition corresponding to the second sub-partition.
[0034] In the case where the backup partition includes a sub-partition (such as the second sub-partition) in the second static partition, after the first system data is re-written to the user partition, the electronic device can restore the data in the second sub-partition, so that the second static partition can continue to be used to back up the data in the first static partition, improving the stability of the system.
[0035] In a second aspect, an electronic device is provided, comprising a memory and a processor, the memory storing a computer program executable on the processor, and the processor executes the computer program to enable the electronic device to implement the steps of the method according to any one of the first aspect.
[0036] In a third aspect, a computer readable storage medium is provided, the computer readable storage medium storing a computer program, and the computer program is executed by a processor to implement the steps of the method according to any one of the first aspect.
[0037] In a fourth aspect, a computer program product is provided, and the computer program product, when executed on an electronic device, enables the electronic device to perform the method according to any one of the first aspect.
[0038] In a fifth aspect, a chip system is provided, the chip system comprising a processor coupled with a memory, and the processor executes a computer program stored in the memory to implement the method according to any one of the first aspect.
[0039] It should be understood that the chip system can be a single chip or a chip module composed of multiple chips.
[0040] It should be understood that the beneficial effects of the second aspect to the fifth aspect can be referred to the related description of the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0041] Figure 1 A user interface diagram of an application scenario to which the embodiments of the present application are applicable is shown;
[0042] Figure 2 A storage architecture diagram of a memory provided by the embodiments of the present application is shown;
[0043] Figure 3 A data change process diagram in a memory provided by the embodiments of the present application is shown;
[0044] Figure 4 An exemplary flowchart of the method 400 provided by the embodiments of the present application is shown;
[0045] Figure 5 An exemplary flowchart of the method 500 to the method 700 provided by the embodiments of the present application is shown;
[0046] Figure 6 A user interface diagram provided by the embodiments of the present application is shown;
[0047] Figure 7 An exemplary block diagram of the method 900 provided by the embodiments of the present application is shown;
[0048] Figure 8 A hardware architecture diagram of an electronic device is shown. DETAILED DESCRIPTION
[0049] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
[0050] The embodiments of the present application provide a method for restoring factory settings, which can be applied to an electronic device. The electronic device can install an operating system so that a user can use the electronic device. The operating system is a software system for controlling and managing hardware and software resources of the electronic device. For example, when the electronic device is a mobile phone, after installing a corresponding operating system (such as an IOS operating system, an Android operating system, etc.) on the mobile phone, the user can use system applications installed by default on the operating system, and can also install some third-party applications.
[0051] In the process of using the electronic device, the user may sometimes perform an operation of restoring factory settings on the operating system. For example, when the user encounters a situation of operating system lag or insufficient storage space, or when the user sells the electronic device, the user may perform an operation of restoring factory settings on the electronic device to clear user data stored on the electronic device for the purpose of privacy protection.
[0052] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. Figure 1 An application scenario to which the embodiments of the present application are applicable is introduced. It should be understood that the electronic device in the embodiments of the present application can be various terminal devices installed with an operating system, such as a mobile phone, a tablet computer, a notebook computer, a personal computer (PC), an ultra-mobile personal computer (UMPC), a handheld computer, a netbook, a smart home device (for example, a smart television, a smart screen, a large screen, a smart speaker, a smart air conditioner, etc.), a personal digital assistant (PDA), a wearable device (for example, a smart watch, a smart bracelet, etc.), a vehicle-mounted device, a virtual reality device, etc., and the embodiments of the present application do not limit this.
[0053] Figure 1 A possible user interface when the electronic device performs the operation of restoring factory settings is shown. In the embodiments of the present application, the electronic device is taken as a mobile phone for example. Figure 1
[0054] Figure 1 (a) shows a user interface 100a in which icons of a plurality of applications are displayed, including one or more system applications (such as the Settings, Camera, Phone, etc. applications) and one or more third-party applications (such as the Life, Shopping, etc. applications). Among them, the system application generally refers to the application program pre-installed in the mobile phone operating system, which is installed on the mobile phone together with the operating system to provide the mobile phone with a basic operating environment and function support. These applications are usually directly integrated into the system firmware by the device manufacturer or operating system provider, and users usually cannot uninstall these applications. While the third-party application generally refers to the application program developed by a third-party software developer independent of the operating system developer. The third-party application on the mobile phone can be downloaded and installed into the mobile phone by the user through the application store during the use of the mobile phone, or it can be pre-installed on the mobile phone when (or after) the operating system is installed. Such pre-installed third-party applications on the mobile phone can be referred to as pre-installed applications. In one possible example, the operating system installation package of the mobile phone carries the installation package of one or more pre-installed applications, and the data package of the pre-installed application is written into the preset partition of the mobile phone memory during the operating system installation process. After the operating system installation is completed, the mobile phone is restarted to take effect, and during the restart process, the mobile phone can automatically install the pre-installed application. That is, the pre-installed application is automatically installed on the mobile phone with the operating system, so when the electronic device installs a new operating system, or upgrades the installed operating system, or performs a factory reset on the operating system, the pre-installed application is automatically installed.
[0055] Referring to Figure 1 Gesture ① in (a): in response to the operation of clicking the icon 101 of the Settings application, the electronic device opens the Settings application and displays the user interface 100b as shown in (b) of Figure 1 It can be understood that the user interface 100b is only a certain function interface within the Settings application, and is not necessarily the default interface of the Settings application, Figure 1 (b) of Figure 1 As shown in (b), the user interface 100b includes a plurality of function controls, including a function control of "factory reset". It can be understood that the "factory reset" displayed by the user interface 100b can also be "factory reset", "format the mobile phone", "factory reset operation", and other text and / or icon instruction information for instructing the first electronic device to perform a factory reset.
[0056] Referring to Figure 1 Gesture ② in (b): in response to the operation of clicking the function control 102 of "factory reset", the mobile phone jumps to the user interface 100c as shown in (c) of Figure 1(c) of FIG. 10B. The user interface 100c includes a prompt 103 and a reset control 104. The prompt 103 is configured to remind the user that the factory reset operation will cause certain data in the phone to be erased. The reset control 104 is configured to trigger the phone to perform the factory reset.
[0057] Referring to Figure 1 the gesture ③ in (c) of FIG. 10B: in response to the operation of clicking the reset control 104, the phone performs the factory reset and displays a user interface 100d as shown in Figure 1 (d) of FIG. 10B. It is to be understood that the user can also input an instruction to the phone in other ways to trigger the phone to perform the factory reset, such as inputting an instruction to the phone to perform the factory reset by voice control, inputting a text instruction, etc., which are not limited in the present application.
[0058] In the process of performing the factory reset, the phone formats the data in the user partition in the memory of the phone (see Figure 2 for the description of the user partition, which is not repeated here), i.e., erases the data in the user partition. The user interface 100d can display the formatting progress in real time, such as the “5%” in the user interface 100d indicating that 5% of the data has been erased.
[0059] After the factory reset is completed, the phone can display a user interface 100e as shown in Figure 1 (e) of FIG. 10B. The user interface 100e includes a prompt that the factory reset is successful, and also includes a prompt that the device will automatically restart.
[0060] After the factory reset is completed, the phone automatically restarts to make the operating system take effect again. Meanwhile, the phone automatically installs the pre-installed applications (if any) in the process of restarting.
[0061] As an example, after the restart, the phone displays a user interface 100f as shown in Figure 1 (f) of FIG. 10B. In the user interface 100f, icons of a plurality of applications are displayed. The applications include one or more system applications (such as camera, phone, clock, calendar, etc.), and optionally, one or more pre-installed applications (such as a shopping application).
[0062] It is to be understood that in the process of performing the factory reset, the third-party applications originally installed by the user in the phone have been erased, and the applications that are retained or re-installed are the system applications and the pre-installed applications. It is also to be understood that the plurality of applications in the user interface 100f are arranged in a pre-set order.
[0063] The above uses a mobile phone as an example to explain in detail the changes in the user interface when an electronic device performs a factory reset. Below, we will combine... Figure 2 and Figure 3 This describes one possible process of storage space changes when an electronic device performs a factory reset.
[0064] Electronic devices typically include a memory, where data such as the operating system and user data can be stored. This application does not limit the storage structure used in the memory of electronic devices; the following describes... Figure 2 This example illustrates one possible storage structure for the memory of an electronic device. It should be understood that... Figure 2 The example in this application uses a virtual A / B partition structure for memory, but this application is not limited to this. That is, the memory of the electronic device in this application can also use other types of data storage structures, such as a full A / B partition structure.
[0065] The following is about Figure 2 The memory partition structure shown is illustrated by example: taking an electronic device with the Android operating system installed as an example, the memory of the electronic device includes a system partition and a user partition.
[0066] First, let's introduce the system partition: The system partition, also known as the system data partition or system space, is used to store system data related to the operating system of an electronic device. It's understood that the system data stored in the system partition is read-only; unless a system upgrade or flashing (such as resetting the firmware) is performed, the system data within the system partition will not change. For convenience, this application will denote the read-only system data stored in the system partition as System Data A.
[0067] System partitions include dynamic partitions (Super) and static partitions. Dynamic partitions are typically used to store system programs. Static partitions include static partition A (slot_A, also known as the first static partition) and static partition B (slot_B, also known as the second static partition). Static partition A and static partition B can each contain multiple subpartitions, such as a boot subpartition and a modem subpartition.
[0068] It should be understood that the number of sub-partitions of the static partition and the naming of the sub-partitions can be different for memories on different electronic devices, and the application only takes the static partition including the boot sub-partition and the modem sub-partition as an example for description, but the application is not limited thereto, and the static partition can further include more or less sub-partitions, and the boot sub-partition and the modem sub-partition can also be named in other ways. For example, the static partition can further include an init_boot sub-partition, an x-loader sub-partition, a bootloader sub-partition, a patch sub-partition, and the like; for another example, the modem sub-partition can also be called a radio sub-partition, and the like.
[0069] Generally, the sub-partition naming of the static partition A and the static partition B is distinguished from each other by the suffixes _a and _b. For example, the sub-partition naming in the static partition A is boot_a, modem_a, and the like, and the sub-partition naming in the static partition B is boot_b, modem_b, and the like.
[0070] In an implementation manner, the static partition A and the static partition B are backups of each other, and their structures correspond to each other, that is, the internal sub-partitions correspond to each other, such as boot_a and boot_b corresponding to each other and modem_a and modem_b corresponding to each other. When the operating system runs in one of the static partitions, the other static partition does not run, but is used for data backup. In this case, the data stored in the corresponding sub-partitions in the two static partitions is consistent.
[0071] For example, when the operating system runs in the static partition A, the static partition B does not run, but is used for backing up the data in the static partition A, specifically, boot_b is used for backing up the data in boot_a, and modem_b is used for backing up the data in modem_a. For another example, when the operating system runs in the static partition B, the static partition A does not run, but is used for backing up the data in the static partition B, specifically, boot_a is used for backing up the data in boot_b, and modem_a is used for backing up the data in modem_b. Assuming that the operating system runs in the static partition A, when the electronic device is powered on, the electronic device will load the static partition A and the dynamic partition in turn under normal circumstances. However, if the static partition A fails to be loaded, the electronic device can attempt to load from the static partition B again, and in this way, the stability of the system can be improved.
[0072] The user partition is introduced as follows: The user partition can also be called a data partition, a user data partition, a user space, and the like, and is used for saving user data, that is, user personal installed application programs (application, APP), user personal saved pictures, documents, and video personal data, and the like.
[0073] In the embodiments of the present application, part of the system data can also be stored in the user partition. Unlike the system data A stored in the system partition, the system data in the user partition is not read-only data, but modifiable data. The system can generate or update the system data in the user partition as needed. For convenience, the present application refers to the modifiable system data stored in the user partition as system data B. By storing system data B in the user partition, on the one hand, the storage space of the system partition can be saved, and on the other hand, the system data B can be optimized and updated according to actual needs.
[0074] The present application does not limit the type of data in the system data B. It should be understood that various modifiable system data can be stored in the user partition according to actual business needs. Two possible data in the system data B are exemplarily described below.
[0075] As an example, the system data B includes model data and / or optimization data.
[0076] The model data refers to resource-based model files, which are the basic data of artificial intelligence models. That is, the model data is used to support the electronic device to process data through the artificial intelligence model (such as a neural network model for face recognition).
[0077] It can be understood that the model data can also be stored in the system partition, and the model data in the system partition is usually stored in the dynamic partition when the operating system is installed. Since the data in the system partition is read-only data, the model data in the system partition cannot be changed, and if a new version of the model is released, the electronic device cannot update the model data in the system partition, therefore, in this case, the new version of the model data can be stored in the user partition. For example, when the electronic device is shipped, the system partition stores the model data of the large model of version 5.0.1, after a period of time, the developer releases the large model of version 5.0.2 in the cloud, the new version of the large model improves the model performance, in order to enable users to experience the characteristics of the new version of the large model, the electronic device can download the model data of the large model of version 5.0.2 from the cloud to the user partition. When in use, the electronic device can select the model data of the large model of a higher version in the system partition and the user partition to use.
[0078] The optimization data refers to data information used for optimizing part or all of the third-party applications in the electronic device, aiming to improve the start speed and / or running speed of the third-party applications. For example, the optimization file can be data in a vdex format integrated with application parsing information and verification information in an Android system. In a possible implementation, the optimization data in the system data B in the embodiment of the present application can refer to optimization data for pre-installed applications.
[0079] Optionally, the system partition of the electronic device can further include an extended memory swap area (MemoryExt). The extended memory swap area is used to support a "smart memory" function, which can also be referred to as a "memory extension" function, and refers to a certain storage space separated from the memory of the electronic device as a running memory (RAM) to increase the space of the running memory, thereby improving the running speed of the electronic device. Therefore, when the "smart memory" function of the electronic device is turned on, the electronic device can use the extended memory swap area as a running space for storing some temporary data.
[0080] It can be understood that the electronic device can also turn off the "smart memory" function. The electronic device can automatically turn on or turn off the "smart memory" function based on a default policy, or turn on or turn off the "smart memory" function according to the user's instruction, which is not limited in the present application.
[0081] It can be understood that, Figure 2 It can be understood that,
[0082] In a possible implementation, a partition table can be provided in the memory, which refers to a data structure or table used by the electronic device to manage disk partitions during storage. As an example, the size and address of each partition can be defined in the partition table. Figure 2 It can be understood that different hardware can adjust the corresponding partition size as needed. For example, part of the data in the partition table is shown in Table 1.
[0083] Table 1
[0084]
[0085] As can be seen from the above, the memory of the electronic device can adopt a partition structure, and different partitions can store different types of data. In the process of restoring the factory settings, the electronic device will clear the data in the user partition. As can be known from the foregoing, not only user data but also system data B can be stored in the user partition, and if the system data B is deleted, it can affect the implementation of part of the system functions of the electronic device, can affect the fluency of the system or software, and can even affect the system running of the electronic device. In view of this, the embodiments of the present application provide a scheme, which can enable the electronic device to automatically reacquire the system data B after restoring the factory settings. The following will be described in combination with Figure 3 The scheme is exemplarily described.
[0086] Figure 3 The (a) in FIG. 1 shows a memory architecture of the electronic device before restoring the factory settings. As an example, the electronic device can currently display the user interface 100a (for the user interface 100a, reference can be made to the corresponding description in the (a) in FIG. 1). Figure 1 The memory of the electronic device currently stores the system data B, and here, taking the system data B including model data and optimization data as an example, in the (a) in FIG. 1. Figure 3 In the (a) in FIG. 1, “Ai_model” represents the model data, and “**vdex” represents the optimization data. It should be understood that the user partition can store optimization data of multiple different third-party applications, that is, “**vdex” can represent optimization data of one or more third-party applications, which is not limited here. In addition, the present application does not limit the storage path of the model data and the optimization data, Figure 3 The (a) in FIG. 1 takes the storage path of the model data as “ / data / system” and the storage path of the optimization data as “ / data / system / vdex” as an example.
[0087] Figure 3 The (b) in FIG. 1 shows a memory architecture of the electronic device after restoring the factory settings. At this time, the electronic device has completed the operation of restoring the factory settings, but has not restarted. As an example, the electronic device can currently display the user interface 100e (for the user interface 100e, reference can be made to the corresponding description in the (e) in FIG. 1). Figure 1 As shown in the (b) in FIG. 1, after the completion of the restoration of the factory settings, the model data and the optimization data in the user partition have been cleared. Figure 3
[0088] Figure 3 (c) of FIG. 10B shows a memory architecture of the electronic device after the electronic device completes the operations of restoring factory settings and restarting. As an example, the electronic device can currently display the user interface 100f (for more information about the user interface 100f, refer to the corresponding description of (f) of FIG. 10B). During the process of restarting the electronic device and / or after the process of restarting the electronic device is completed, the electronic device can automatically obtain the model data and the optimization data, for example, the electronic device re-downloads the model data through the cloud and re-compiles the calculation of the optimization data through the local compiler. The electronic device can obtain part of the data in the system data B (such as high-priority data that can affect the operation of the system) during the process of restarting, and obtain the remaining data after the process of restarting is completed. Figure 1 (f) of FIG. 10B) during the process of restarting the electronic device and / or after the process of restarting the electronic device is completed, the electronic device can automatically obtain the model data and the optimization data, for example, the electronic device re-downloads the model data through the cloud and re-compiles the calculation of the optimization data through the local compiler. The electronic device can obtain part of the data in the system data B (such as high-priority data that can affect the operation of the system) during the process of restarting, and obtain the remaining data after the process of restarting is completed.
[0089] Therefore, through the scheme shown in Figure 3 Therefore, through the scheme shown in
[0090] However, the above scheme can cause the electronic device to have problems such as serious device heating, phone running lag, network lag, and the like after the electronic device restores factory settings, which affects the user experience. For example, if the electronic device obtains part of the data in the system data B (such as part of the optimization data generated by compiling) during the process of restarting after the electronic device completes the operation of restoring factory settings, the time of restarting will be longer, which will make the user wait for a longer time, and thus affect the user experience. For another example, the electronic device connects to the network to download the model data from the cloud after the process of restarting is completed. Since the model data is usually large (such as 4G), the time of downloading will also be long, and this period of time will occupy the network of the electronic device, which can cause the network to be lagged when the user uses other network services. For another example, the electronic device generates the optimization data through the local compiler after the process of restarting is completed, which will make the power consumption of the electronic device be high, and the heating will be more, which can affect the fluency of the overall operation of the electronic device.
[0091] In view of the above problems, the embodiments of the present application provide a method for restoring factory settings, in which a part of space in the user partition is divided to be used as a backup partition, and the system data C (the system data C is part or all of the system data B) is temporarily stored in the backup partition in the user partition before the factory settings are restored. After the factory settings are restored, the system data C is restored from the backup partition to the user partition. This scheme can restore the system data C to the user partition as soon as possible after the electronic device completes the factory settings, improve the efficiency of data recovery, and at the same time, avoid the occupation of the network in the process of restoring the system data C, and reduce the power consumption and heating of the electronic device in the process. The following will be described in combination with the method 400 in Figure 4 The embodiments of the present application provide a possible implementation of the scheme.
[0092] S401, the electronic device calculates a hash value based on the system data C and stores the hash value to boot_b.
[0093] Illustratively, in order to improve the reliability of the data, the hash value of the data to be backed up can be calculated before the factory settings are restored, so that the integrity of the backup data can be verified by using the hash value subsequently. The verification process can refer to the description of steps S403, S406 and S409, which will not be described here.
[0094] In the embodiments of the present application, the system data C is used to represent the data to be backed up. The system data C can be part or all of the system data B. That is, the electronic device can backup all the system data stored in the user partition, or only backup part of the data, which is not limited by the present application.
[0095] In a possible implementation, in response to an operation indicating that the electronic device performs the factory settings, the electronic device calculates a hash value based on the system data C. For example, in the example shown in (c) of Figure 1 In a possible implementation, in response to an operation indicating that the electronic device performs the factory settings, the electronic device calculates a hash value based on the system data C. For example, in the example shown in (c) of
[0096] It can be understood that the hash value, also known as the hash value, is data composed of a binary sequence of a specific length, and is usually used as a unique identifier of data. Any length of data (such as a string, a file, etc.) can be mapped to a fixed length binary value by a hash algorithm. The present application does not limit the hash algorithm used by the electronic device when calculating the hash value, but it should be understood that the data length of the hash value is usually determined by the hash algorithm, for example, the SHA-256 algorithm can generate a 256-bit (32-byte) hash value, and the SHA-384 algorithm can generate a 384-bit (48-byte) hash value. The electronic device can record the data length of the hash value, or the hash algorithm used when calculating the hash value, so that when the hash value is used later, the hash value can be correctly read from the storage space. For details, see the description of step S403 below, which will not be described here.
[0097] In a possible implementation, after calculating the hash value, the electronic device stores the hash value in the free partition of the system partition. That is, the hash value is temporarily stored in the free partition of the system partition by the embodiment of the present application.
[0098] It should be noted that the free partition in the embodiment of the present application refers to the partition in an idle state during the recovery process. That is, in normal circumstances, the electronic device is in an idle state during the recovery process, that is, the partition is in an idle state, that is, it does not need to read data from the partition, nor does it need to write data to the partition. For example, the free partition is any sub-partition of the non-operating static partition, wherein the non-operating static partition refers to the static partition currently used for data backup, for example, in the case where the operating system of the electronic device is currently running in the static partition A, the static partition B is a non-operating static partition, at this time, any sub-partition (such as boot_b, or init_boot_b, or x-loader_b, or modem_b, etc.) in the static partition B. For another example, the free partition is an extended memory swap area with memory extension feature turned off. The extended memory swap area is used to support the "smart memory" function, when the electronic device turns off the "smart memory" function, the memory extension feature of the extended memory swap area is also turned off, at this time, the extended memory swap area is in an idle state. Therefore, if the extended memory swap area is used to store the hash value, the "smart memory" function can be turned off first to prevent subsequent other data from "polluting" the hash value in the extended memory swap area.
[0099] In the embodiment, it is assumed that the static partition B is a free partition, and the storage of the hash value in boot_b is taken as an example for description.
[0100] It can be understood that in the scheme provided in the embodiments of the present application, the hash value is stored in the system partition, mainly to ensure the stability of the data. The space occupied by the hash value is very small, and it is relatively easy to find a free partition in the system partition for storing the hash value, and the free partition in the system partition does not participate in the recovery factory setting process, so the reliability of the hash value can be ensured. At the same time, the scheme can also ensure that the storage location of the hash value is different from the backup location of the system data, thereby improving the security of the data.
[0101] In a possible implementation, when the electronic device writes the hash value into boot_b, the electronic device can directly use the hash value to overwrite the original data in boot_b. In this way, the electronic device can record the length of the hash value, or calculate the hash algorithm used by the hash value, so as to correctly read the hash value from boot_b subsequently. In another possible implementation, before the electronic device writes the hash value into boot_b, the electronic device can first format boot_b (that is, clear all data in boot_b), and then write the hash value into boot_b.
[0102] In a possible implementation, the electronic device can determine which data to backup according to the configuration file, that is, the electronic device determines the system data C according to the configuration file. After determining the system data C according to the configuration file, the hash value is calculated based on the system data C.
[0103] Optionally, the electronic device can also determine the storage location of the hash value according to the configuration file. For example, the electronic device determines to store the hash value into boot_b according to the configuration file.
[0104] It can be understood that the above configuration file can be pre-configured in the product components of the electronic device.
[0105] S402, the electronic device partitions the user partition from the user partition.
[0106] For example, the electronic device partitions the user partition from the tail of the user partition, that is, the electronic device partitions the space from the back to the front of the user partition until a space with a preset size (such as 8G) is partitioned, and then the partitioned space is used as the user partition.
[0107] The reason for partitioning the space from the tail of the user partition is that the present scheme hopes to avoid damaging the system data C as much as possible when partitioning the space, because if the system data C is damaged, even if the data is backed up, the data cannot be normally used after the electronic device is started subsequently. The data in the user partition is usually stored from front to back, so the probability of empty space in the tail is relatively large, so partitioning the space from the tail of the user partition can avoid damaging the system data C as much as possible.
[0108] In a possible implementation, the preset size is a value preconfigured on the electronic device.
[0109] In another possible implementation, the preset size is a value determined by the electronic device based on the size of the system data C. It should be understood that the preset size should be no less than the size of the system data C.
[0110] In yet another possible implementation, the electronic device determines the preset size based on the configuration file.
[0111] It can be understood that step S402 should be executed after step S401, that is, the electronic device should first calculate the hash value and store the hash value to boot_b, and then split the user partition from the user partition. Because the electronic device may damage the system data C in the user partition when executing step S402, and the hash value is originally used to verify the integrity of the system data C, therefore the hash value must be calculated under the condition of ensuring the integrity of the system data C.
[0112] Optionally, in a possible implementation, before executing step S402, the electronic device can first determine the size of the data to be backed up (that is, the system data C). In the case that the size of the system data C is greater than or equal to a preset threshold (such as 3G), step S402 is executed. Because the space of the user partition is relatively large, if there is a large amount of data to be backed up (such as data exceeding 3G), the scheme provided by the present application can be used, that is, the user partition is split to obtain the user partition* as the backup partition. If the data to be backed up (that is, the system data C) is relatively small (such as less than 3G), the electronic device can not execute step S402, but backup the system data C to the free partition of the system partition, because compared with the user partition, the system partition is more stable, and does not need to perform the space splitting operation.
[0113] S403, the electronic device verifies the integrity of the system data C in the user partition by using the hash value.
[0114] Exemplarily, after completing the space splitting in step S402, the electronic device verifies the integrity of the system data C in the user partition by using the hash value.
[0115] As described above, there is a risk of damaging the system data C in the process of space splitting, and once the system data C is damaged, the data backup loses its meaning. Therefore, after the space splitting (that is, after step S402) and before the data backup (that is, before step S405), the electronic device verifies the integrity of the system data C in the user partition by using the hash value.
[0116] For example, the electronic device reads the hash value from the boot_b, and then uses the hash value to check the integrity of the system data C. For a specific example, the electronic device uses the same hash algorithm to recalculate the hash value according to the system data C in the user partition, and if the hash value is the same as the hash value*, it means that the integrity check is passed, and the electronic device continues to execute the subsequent process, otherwise the electronic device terminates the data backup process, but merges the user partition* back to the user partition, and performs the factory reset.
[0117] It can be understood that the electronic device can read the hash value from the boot_b according to the data length of the hash value. The data length of the hash value is usually determined by the hash algorithm, for example, the SHA-256 algorithm can generate a 256-bit (32-byte) hash value, and the SHA-384 algorithm can generate a 384-bit (48-byte) hash value.
[0118] Optionally, S404, the electronic device formats the user partition*.
[0119] For example, the embodiment of the application backs up the system data C through the user partition*. In order to avoid the original data in the user partition* from interfering with the backup data, the electronic device can format (i.e. empty all data in the user partition*) the user partition* before formally performing data backup (i.e. before executing step S405).
[0120] S405, the electronic device stores the system data C to the user partition*.
[0121] For example, in the method 400, the user partition* is used as a backup partition. Therefore, the electronic device stores the system data C to the user partition* after the integrity check of the system data C in the user partition is passed.
[0122] In a specific example, the electronic device finds and copies the system data C from the user partition, and then writes the system data C to the user partition* according to blocks.
[0123] It can be understood that the electronic device can also directly migrate the system data C to the user partition*, that is, the electronic device can delete the system data C in the original user partition while backing up the system data C, which can improve the speed of subsequent formatting of the user partition.
[0124] Optionally, S406, the electronic device checks the integrity of the system data C in the user partition* using the hash value.
[0125] Exemplarily, after the backup of the system data C is completed, the integrity of the data backed up in the user partition * can be checked again by the hash value. Because the data damage can also occur in the process of data backup.
[0126] If the integrity check of the system data C passes, the subsequent process of restoring the factory setting is continued.
[0127] If the integrity check of the system data C fails, in a possible implementation, the electronic device formats the user partition * and then re-executes the step S405. That is, the electronic device re-executes the data backup once. Because the precondition of executing the step S405 is that the check in the step S403 passes, the data is likely to be damaged in the process of backup, and thus the system data C can be written into the user partition * again. After the system data C is backed up again, the system data C newly written in the user partition * is checked again by the hash value. If the check passes, the subsequent process of restoring the factory setting is continued. If the check fails, the user partition * is formatted and the user partition * is merged into the user partition, and then the process of restoring the factory setting is continued.
[0128] S407, the electronic device empties the data in the user partition.
[0129] Exemplarily, after the steps S401-S406 are completed, the electronic device executes the restoration of the factory setting. In the process of executing the restoration of the factory setting, the electronic device empties the data in the user partition.
[0130] It can be understood that, in the process of executing the restoration of the factory setting, the electronic device only needs to execute the restoration of the factory setting in one of the user partition and the user partition *. In the embodiment of the present application, the electronic device executes the restoration of the factory setting in the user partition, and formats the user partition in the process of restoring the factory setting. The user partition * does not participate in the process of restoring the factory setting, and thus the data (i.e., the system data C) in the user partition * is not formatted.
[0131] S408, the electronic device rewrites the system data C into the user partition.
[0132] Exemplarily, after the restoration of the factory setting is completed, the electronic device restores the system data C from the backup partition to the user partition.
[0133] In a possible implementation (denoted as mode A), the electronic device copies the system data C from the user partition * and then writes the system data C into the user partition by block.
[0134] In another possible implementation (denoted as mode B), the electronic device directly migrates the system data C from the user partition * to the user partition.
[0135] S409, the electronic device verifies the integrity of the system data C in the user partition by using the hash value.
[0136] Exemplarily, after the system data C is restored to the user partition, the electronic device verifies the integrity of the system data C in the user partition by using the hash value.
[0137] On the basis of the above-mentioned manner A, in the case that the integrity verification of the system data C in the user partition is passed, the electronic device formats the system partition, and then continues to execute the subsequent process. In the case that the integrity verification of the system data C in the user partition is not passed, the electronic device can format the user partition, and then re-executes the steps S408 and S409. Of course, in the case that the integrity verification of the system data C in the user partition is not passed, the electronic device can also directly give up the backed-up data, directly format the user partition and the user partition, and then execute the subsequent process.
[0138] On the basis of the above-mentioned manner B, in the case that the integrity verification of the system data C in the user partition is passed, the electronic device continues to execute the subsequent process. In the case that the integrity verification of the system data C in the user partition is not passed, the electronic device can format the user partition, and then continues to execute the subsequent process.
[0139] S410, the electronic device merges the user partition and the user partition.
[0140] Exemplarily, the electronic device merges the user partition into the user partition.
[0141] It can be understood that, no matter whether the foregoing data recovery process is successful or not, the electronic device needs to execute the step S410 to avoid the influence of the space division operation on the user business.
[0142] Before merging the user partition into the user partition, the electronic device can first determine that the user partition has been formatted.
[0143] S411, the electronic device copies the data in boot_a to boot_b.
[0144] Exemplarily, after the electronic device restores the system data C to the user partition again, it also needs to restore the data in the free partition (this embodiment takes boot_b as an example) for storing the hash value again.
[0145] As mentioned above, static partition A and static partition B are backups of each other, and the data in the corresponding sub-partitions in static partition A and static partition B are originally consistent. Therefore, to restore the data in boot_b, the data in boot_a can be copied to boot_b. In one implementation, the electronic device copies the data in boot_a, and then directly overwrites the data in boot_b. In another possible implementation, the electronic device formats boot_b first, and then copies the data in boot_a to boot_b.
[0146] It can be understood that if the electronic device uses the extended memory swap area to store the hash value, the electronic device can also restart the "smart memory" function after restoring the system data C to the user partition. It can be understood that in this implementation, the electronic device can not need to restore the data in the extended memory swap area, because the extended memory swap area is originally a temporary data area, and therefore does not need to restore the data therein. Of course, the electronic device can also clear the data (i.e., the hash value) in the extended memory swap area.
[0147] In summary, in the method 400 provided in the embodiments of the present application, part of the user partition of the electronic device is divided as a backup partition for backing up the system data C stored in the original user partition. After the electronic device performs the factory reset, the system data C in the original user partition is cleared. If the electronic device reacquires the system data C by using the cloud download and / or local compilation, it can cause the electronic device to have serious heating, network lag, and unsmooth system, etc. In the solution provided in the embodiments of the present application, the system data C can be directly restored from the backup partition to the user partition after the factory reset is completed, which can improve the efficiency of data recovery, avoid the occupation of the network in the process of restoring the system data C, and reduce the power consumption and heating of the electronic device in the process.
[0148] In the above method 400, one of static partition A and static partition B can be used to store the hash value, because static partition A and static partition B are backups of each other, the data in the two partitions are consistent, and the operating system of the electronic device only runs in one of the static partitions, and therefore the other static partition is in an idle state (i.e., an unrunning state). Therefore, even if the static partition is used for other purposes, it will not affect the factory reset process.
[0149] However, the data in static partition A and static partition B is not always consistent. For example, when the operating system of the electronic device is upgraded, upgrade data is written to one of the static partitions, which can cause the data in the two static partitions to be inconsistent. The following is an illustrative example.
[0150] Assume that the current operating system runs in static partition A, and the version of the operating system is version 1. The electronic device can obtain an upgrade data package through over-the-air technology (OTA), the upgrade data package including upgrade data of different partitions (such as static partition upgrade data, dynamic partition upgrade data), and can be used to upgrade the operating system from version 1 to version 2. OTA refers to a technology for remotely updating the operating system of the electronic device through the wireless network interface of the electronic device.
[0151] It can be understood that version 2 can be the version of the operating system that the electronic device needs to reach after upgrading, can be the version of the latest released operating system, or can be the version of the operating system specified by the user to backtrack, and the present application does not limit this. Of course, different upgrade data packages are required to upgrade to different operating system versions.
[0152] After obtaining the upgrade data package and passing the verification of the upgrade data package, the update engine in the electronic device can write the static partition upgrade data in the upgrade data package to static partition B. Specifically, the update engine can write the upgrade data in the boot sub-partition in the upgrade data package to boot_b, write the upgrade data in the modem sub-partition in the upgrade data package to modem_b, and so on. That is, if the operating system of the electronic device currently runs in static partition A, during the system upgrade process, the update engine writes the static partition upgrade data in the upgrade data package to static partition B. Since the data in static partition A and static partition B is originally consistent, after the static partition upgrade data is written to static partition B, the data in static partition A and static partition B will be inconsistent before the system upgrade is started and completed.
[0153] During the process of writing data to static partition B, static partition B can no longer be regarded as an idle partition. In this case, the execution of the factory reset can be suspended, and a response prompt can be displayed to the user. The following will be described in combination with Figure 5 The three possible schemes are exemplarily described.
[0154] Figure 5 (a) in FIG. 5 shows an exemplary flowchart of the method 500a provided by the embodiment of the present application. The following will exemplarily describe the specific implementation process of the method 500a.
[0155] S501, the electronic device receives an instruction indicating that the electronic device performs the factory reset.
[0156] S502, the electronic device calculates the hash values of the corresponding sub-partitions in static partition A and static partition B.
[0157] For example, after receiving the instruction indicating the electronic device to perform the factory reset, the electronic device calculates the hash values of the corresponding sub-partitions in the static partition A and the static partition B. For example, referring to (c) in FIG. 8, after detecting the click operation on the control 104, the electronic device calculates the hash values of the corresponding sub-partitions in the static partition A and the static partition B. For example, the electronic device calculates the hash values of the data in boot_a and boot_b, and the hash values of the data in modem_a and modem_b, and so on. Figure 1 For example, after receiving the instruction indicating the electronic device to perform the factory reset, the electronic device calculates the hash values of the corresponding sub-partitions in the static partition A and the static partition B. For example, referring to (c) in FIG. 8, after detecting the click operation on the control 104, the electronic device calculates the hash values of the corresponding sub-partitions in the static partition A and the static partition B. For example, the electronic device calculates the hash values of the data in boot_a and boot_b, and the hash values of the data in modem_a and modem_b, and so on.
[0158] S503, the electronic device determines that the hash values of any group of sub-partitions are different.
[0159] For example, in the embodiments of the present application, a group of sub-partitions refers to a group of partitions composed of corresponding sub-partitions in the static partition A and the static partition B, such as boot_a and boot_b being a group of sub-partitions, modem_a and modem_b being a group of sub-partitions, init_boot_a and init_boot_b being a group of sub-partitions, and so on.
[0160] If the hash values of any group of sub-partitions are different, the electronic device performs step S504a, otherwise the electronic device performs step S505.
[0161] S504, the electronic device displays prompt information.
[0162] In an application scenario, in addition to the system upgrade process, the data in the corresponding sub-partitions in the static partition A and the static partition B is always consistent, so when the hash values of at least one group of sub-partitions are different, it represents that the current is in the system upgrade process, and the electronic device can temporarily not perform the factory reset, and display prompt information, for example, to prompt the user to perform the factory reset later, such as the prompt information 801 shown in (b) in FIG. 8. Figure 6
[0163] S505, the electronic device continues to perform the method 400.
[0164] For example, if the data in all corresponding sub-partitions in the static partition A and the static partition B is consistent, it means that the electronic device is not currently in the system upgrade process, so one of the static partition B and the static partition A is currently an idle partition and can be used for data backup, so the electronic device can continue to perform the method 400. That is, the method 500 can be performed before the method 400.
[0165] Figure 5 (b) in FIG. 8 shows an exemplary flowchart of the method 600 provided by the embodiments of the present application. The specific implementation process of the method 600 is exemplarily described below.
[0166] S601, the electronic device receives an instruction indicating that the electronic device performs factory reset.
[0167] S602, the electronic device determines whether the electronic device is currently in a system upgrade process.
[0168] For example, after receiving the instruction indicating that the electronic device performs factory reset, the electronic device determines whether the electronic device is currently in a system upgrade process. For example, referring to (c) in FIG. 1B, after detecting the click operation on the control 104, the electronic device determines whether the electronic device is currently in a system upgrade process. Figure 1
[0169] The present application does not limit the specific implementation of the electronic device determining whether the electronic device is in a system upgrade process. In an example, the electronic device determines whether the path “ / data / gsi / ota” in the memory is empty. If the path is empty, it indicates that the electronic device is not currently in a system upgrade process. If the path is not empty, it indicates that the electronic device is currently in a system upgrade process. It can be understood that during the system upgrade process, the electronic device will write a cache file to the path “ / data / gsi / ota”, so whether the path is empty can be used to determine whether the electronic device is currently in a system upgrade process.
[0170] S603, the electronic device displays prompt information.
[0171] For example, if the system is currently running in the static partition A, during the system upgrade process, the upgrade data will be written to the static partition B, at this time, the static partition B cannot be used as a backup partition, therefore the electronic device can temporarily not perform factory reset, and display prompt information, for example, the prompt information is used to prompt the user to perform factory reset later, as shown by the prompt information 801 in FIG. 1C. Figure 6
[0172] S604, the electronic device continues to perform the method 400.
[0173] For example, if the electronic device is not currently in a system upgrade process, one of the static partition B and the static partition A is currently an idle partition, and can be used for data backup, therefore the electronic device can continue to perform the method 400. That is, the method 600 can be performed before the method 400.
[0174] It can be understood that in some special scenarios, the data in the static partition A and the static partition B can be different even if the system is not in the system upgrade process, and thus by directly determining whether the electronic device is currently in the upgrade process, it can be more accurate to determine whether one of the static partition A and the static partition B can be used as the backup partition. That is, compared with the method 500, the method 600 can adapt to more application scenarios.
[0175] Figure 5 (c) in the above shows an exemplary flowchart of the method 700 provided by the embodiments of the present application. It can be understood that the method 700 is a solution obtained by combining the method 500 and the method 600, that is, in the method 700, it is not only to determine whether the hash values of any group of sub-partitions in the static partition A and the static partition B are different, but also to determine whether the current system is in the upgrade process. Only when the hash values of each group of corresponding sub-partitions in the static partition A and the static partition B are the same and the current system is not in the upgrade process, the method 400 can be continued to be executed, otherwise, a prompt information is displayed to the user. It should be understood that the steps S701-S703 in the method 700 are similar to the steps S501-S503 in the method 500, the step S704 in the method 700 is similar to the step S602 in the method 600, the step S705 in the method 700 combines the step S504 in the method 500 and the step S603 in the method 600, the step S706 in the method 700 combines the step S405 in the method 500 and the step S604 in the method 600, and for the sake of brevity, the descriptions are not repeated here.
[0176] It can be understood that compared with the method 500 and the method 600, the method 700 further improves the reliability of the solution.
[0177] Figure 7 An exemplary block diagram of the method 900 provided by the embodiments of the present application is shown. It can be understood that the above method 400 can be regarded as a possible implementation manner of the method 900 in a specific application scenario, and thus the description in the method 400 is also applicable to the method 900, and the subsequent description not described in detail can be referred to the description in the method 400.
[0178] S910, in response to triggering the electronic device to execute the operation of restoring the factory settings, splitting the backup partition from the user partition.
[0179] Exemplarily, the method 900 is applied to an electronic device including a memory. The present application does not limit the specific storage structure of the memory, and as an example, the memory can adopt the storage structure as shown in Figure 2
[0180] The memory includes a user partition and a system partition. The user partition stores first system data, which is system data of a modifiable type. In the process of restoring factory settings, the user partition is formatted, which results in the first system data being deleted. The deletion of the first system data can cause part of the system functions (such as AI functions) of the electronic device to be limited, or even cause the system to run into problems.
[0181] In view of this, embodiments of the present application split a part of the user partition as a backup partition. After detecting a trigger for the electronic device to perform the operation of restoring factory settings (such as the scenario shown in (c) in FIG. 1, detecting a click operation on the control 104), the electronic device writes the first system data in the user partition to the backup partition. For example, the electronic device reads and copies the first system data from the user partition, and then writes the first system data to the backup partition in blocks. Figure 1
[0182] That is, in the method 900, the first system data is the to-be-backed-up data stored in the user partition, which can be all system data in the user partition or part of the system data in the user partition. It can be understood that the first system data is system data of an editable type. In order to back up the first system data, the present application splits a part of the original user partition as a backup partition, which is used to temporarily store the first system data in the process of restoring factory settings. Therefore, the first system data can correspond to the system data C in the method 400, and the backup partition can correspond to the user partition in the method 400.
[0183] The present application does not limit the specific implementation manner of the electronic device to split the space. In one possible example, the electronic device splits a backup partition of a preset size from the tail of the user partition.
[0184] In one possible implementation manner, the preset size is a value preconfigured on the electronic device.
[0185] In another possible implementation manner, the preset size is a value determined by the electronic device based on the size of the system data C. It should be understood that the preset size should not be less than the size of the system data C.
[0186] In yet another possible implementation manner, the electronic device determines the preset size based on a configuration file.
[0187] In addition, the reason why the space partitioning (which refers to the operation of partitioning the user partition to obtain the backup partition) is performed from the tail of the user partition is that the present scheme aims to avoid damaging the first system data as much as possible during the space partitioning, because if the first system data is damaged, even if the data is backed up, the data cannot be normally used after the electronic device is powered on. The data in the user partition is usually stored from front to back, and therefore the probability of the tail space being empty is relatively high, so the space partitioning from the tail of the user partition can avoid damaging the first system data as much as possible.
[0188] Optionally, in a possible implementation, before performing the space partitioning, the electronic device can first determine the size of the first system data. In a case where the size of the first system data is greater than or equal to a preset threshold, the backup partition is partitioned from the user partition.
[0189] Because the space of the user partition is relatively large, if there is relatively large data to be backed up (for example, data greater than 3G), the scheme provided in the present application can be used, that is, the backup partition is partitioned from the user partition. If the data to be backed up (that is, the first system data) is relatively small (for example, less than 3G), the electronic device can not perform step S910, but can back up the first system data to the free partition of the system partition, because the system partition is more stable than the user partition, and does not need to perform the space partitioning operation.
[0190] Optionally, in a possible implementation, in order to improve the reliability of the data, the hash value of the data to be backed up can be calculated before the factory reset is performed, so that the hash value can be used to verify the integrity of the backup data in the future. The electronic device can calculate the hash value according to the first system data in the user partition before partitioning the backup partition from the user partition.
[0191] For example, in addition to the user partition, the memory also includes a system partition. After the hash value is calculated, the electronic device can store the hash value in the first sub-partition of the system partition of the memory. The first sub-partition is a free partition in the system partition during the process of performing the factory reset, that is, the first sub-partition does not run during the process of performing the factory reset of the electronic device, that is, neither data needs to be written to the backup partition nor data needs to be read from the backup partition. Therefore, even if the backup partition is used for other purposes during the process of performing the factory reset, the process of the electronic device performing the factory reset will not be affected.
[0192] It can be understood that in the scheme provided in the embodiments of the present application, the hash value is stored in the system partition, mainly to ensure the stability of the data. The space occupied by the hash value is very small, and it is relatively easy to find a free partition in the system partition for storing the hash value, and the free partition in the system partition does not participate in the recovery factory setting process, so the reliability of the hash value can be ensured. At the same time, the scheme can also ensure that the storage location of the hash value is different from the backup location of the system data, thereby improving the security of the data.
[0193] Optionally, in a possible implementation, the electronic device can determine the data to be backed up, i.e., the first system data, based on the configuration file.
[0194] It should be understood that the operating system of the electronic device is currently running in the first static partition, and the first static partition and the second static partition both belong to the system partition of the electronic device, and the first static partition and the second static partition are backups of each other. That is, the first static partition can correspond to the static partition A in the method 400, and the second static partition can correspond to the static partition B in the method 400.
[0195] The first sub-partition can include one or more sub-partitions in the second static partition, such as a modem sub-partition, a boot sub-partition, an init_boot sub-partition, and the like.
[0196] Optionally, in the case where the first sub-partition includes at least one sub-partition in the second static partition, i.e., the electronic device uses at least one sub-partition in the second static partition to store the hash value, the electronic device can determine whether the second static partition is currently in an idle state before performing step S910. If the second static partition is currently in an idle state, the subsequent data backup and recovery factory setting process can be normally performed; and if the second static partition is not currently in an idle state, any sub-partition in the second static partition cannot be used to store the hash value any more, at which time the recovery factory setting process can be temporarily suspended, and a corresponding prompt information (such as Figure 6(See prompt message 801 in the original text). The following is an example of a possible implementation: After detecting a factory reset operation, the electronic device checks whether the data in the corresponding sub-partitions of the first and second static partitions is consistent. Since in one application scenario, the data in the corresponding sub-partitions of the first and second static partitions is completely consistent, and inconsistencies only occur during system upgrades, if at least one set of corresponding sub-partitions in the first and second static partitions are inconsistent, it indicates that a system upgrade is currently in progress, and the factory reset process can be temporarily suspended. Only when the data in the corresponding sub-partitions of the first and second static partitions is confirmed to be consistent does the electronic device execute method 900. The specific implementation process of this scheme can also be found in the description of method 500. The following is an example of another possible implementation: When the system is currently running on the first static partition, if a system upgrade process is executed, upgrade data will be written to the second static partition, making the second static partition not idle. Therefore, the electronic device can also directly determine whether a system upgrade process is currently in progress. For example, the electronic device checks whether the preset storage path (e.g., " / data / gsi / ota") is empty. This preset storage path is used to store cached data generated during the system upgrade process. If this path is not empty, it indicates that the electronic device is undergoing a system upgrade, and the factory reset process can be temporarily suspended. Only when the preset storage path is empty will the electronic device execute method 900. The specific implementation process of this solution can be found in the description of method 600. It is understood that the above two implementation methods can also be combined; the specific method can be found in the description of method 700, which will not be repeated here.
[0197] On the other hand, the extended memory swap area supports a first function of the electronic device, which sets the extended memory swap area as the running memory of the electronic device. This first function corresponds to the aforementioned "smart memory" function. When the first function is enabled, the electronic device can use the extended memory swap area as running memory. When the first function is disabled, the extended memory swap area is idle. Therefore, when the first subpartition includes the extended memory swap area, i.e., the electronic device uses the extended memory swap area to store hash values, the electronic device disables the first function before writing the hash values to the backup partition.
[0198] S920 reads the first system data from the user partition, writes the first system data to the backup partition, and then performs a factory reset.
[0199] For example, after completing the space partitioning (i.e. obtaining the backup partition), the electronic device can write the first system data in the user partition to the backup partition.
[0200] For example, in one specific example, the electronic device looks up and copies the first system data from the user partition, and then writes the first system data in blocks to the backup partition.
[0201] It can be understood that the electronic device can also directly migrate the first system data to the backup partition, that is, the electronic device can delete the first system data in the original user partition while backing up the first system data, which can improve the speed of subsequent formatting of the user partition.
[0202] Optionally, the electronic device formats the backup partition before writing the first system data to the backup partition.
[0203] Optionally, the electronic device can also verify the integrity of the first system data in the user partition by using the hash value before writing the first system data to the backup partition. In a case where it is determined that the integrity verification of the first system data is passed, step S920 is performed.
[0204] It can be understood that the reason for performing step S920 only in a case where the integrity verification of the first system data is passed is that the electronic device can damage the first system data in the original user partition when performing step S910, and the hash value is originally used to verify the integrity of the first system data, so the hash value must be calculated in a case where the integrity of the first system data is ensured.
[0205] S930, after completing the recovery of the factory setting, reading the first system data from the backup partition and writing the first system data to the user partition again.
[0206] For example, the electronic device recovers the first system data from the backup partition to the user partition after performing the recovery of the factory setting, so that the heat condition or the occupation of the network caused by the regeneration of the first system data can be avoided, and the power consumption of the device can also be reduced.
[0207] Optionally, in one possible implementation, after writing the first system data to the user partition again, the electronic device can also verify the integrity of the first system data in the user partition by using the hash value. In a case where the verification fails, the user partition is formatted. Or, in a case where the verification fails, the user partition is formatted, and then step S903 is performed again. That is, the first system data is written to the user partition again, and then the integrity of the first system data in the user partition is verified again by using the hash value.
[0208] In a possible implementation, after the first system data is re-written into the user partition, the electronic device merges the backup partition into the user partition. Optionally, in this implementation, the electronic device formats the backup partition before merging the backup partition into the user partition.
[0209] Optionally, in a possible implementation, in the case that the first sub-partition includes a sub-partition in the second static partition (for example, the second sub-partition), after the first system data is re-written into the user partition, the electronic device can restore data in the second sub-partition, so that the second static partition can continue to be used to back up data in the first static partition, improving the stability of the system. For example, the electronic device copies data in a third sub-partition to the second sub-partition, where the third sub-partition belongs to the first static partition, and the third sub-partition corresponds to the second sub-partition.
[0210] To sum up, in the method 900 described above, part of the user partition of the electronic device is divided as a backup partition for temporarily storing first system data. In the process of performing the factory reset, the electronic device selects the original user partition to perform the factory reset, so that the data in the backup partition can be preserved in the process of factory reset, and at the same time, the normal progress of the factory reset process is not affected. After the first system data is backed up to the backup partition, the factory reset process can be normally performed, and after the factory reset process is completed, that is, after the user partition is formatted, the first system data is directly restored to the user partition from the backup partition, which can improve the efficiency of data recovery, and at the same time, some problems caused by the regeneration of the first system data can be avoided, such as serious device heating, network lag, system lag, etc.
[0211] Figure 8 FIG. 1 is a schematic diagram of a hardware structure of an electronic device 1000 provided by an embodiment of the present application. As shown in FIG. 1, the electronic device 1000 can include a processor 1010, a memory 1020, a mobile communication module 1030, and a wireless communication module 1040. Optionally, it can further include a sensor 1050 and a display screen 1060. Figure 8
[0212] It can be understood that the structure shown in this embodiment does not constitute a specific limitation on the electronic device 1000. In other embodiments, the electronic device 1000 can include more or fewer components than those shown in the figure, or combine certain components, or split certain components, or different arrangement of components. The components shown in the figure can be implemented in hardware, software, or a combination of software and hardware.
[0213] The processor 1010 can include one or more processing units, for example: the processor 1010 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units can be independent devices, or can be integrated in one or more processors.
[0214] The memory 1020 can be used to store computer-executable program code including instructions. The processor 1010 performs various functional applications and data processing of the electronic device 1000 by running the instructions stored in the memory 1020.
[0215] Exemplarily, in the technical solutions provided in the embodiments of the present application, the starting, factory resetting, operating system upgrading and the like of the electronic device 1000 mainly depend on the related instructions stored in the memory 1020 in advance, and the processor 1010 executes the instructions stored in the memory 1020, so as to enable the electronic device 1000 to perform the factory resetting method provided in the embodiments of the present application.
[0216] The present application does not limit the memory structure of the memory 1020. In a possible implementation manner, the memory can adopt the structure as shown in Figure 2 In an example, the memory 1020 includes a system partition 1020a and a user partition 1020b. The system partition 1020a is used to store system data related to the operating system of the electronic device, and the system data is read-only type data. The user partition 1020b is used to save user data, which refers to the personal data of the user, such as the application programs installed by the user, the pictures, documents and videos saved by the user, etc. In the embodiments of the present application, part of the system data can also be stored in the user partition. Unlike the system data stored in the system partition, the system data in the user partition is not read-only type data, but modifiable type data. The system can generate or update the system data in the user partition as needed.
[0217] In the process of performing the factory reset, the electronic device formats the user partition 1020b, i.e., clears the user data and the system data stored in the user partition 1020b. In the scheme provided in the embodiments of the present application, a part of the space in the user partition 1020b can be divided as a backup partition to backup the system data in the user partition 1020b, and the backup data can be restored to the user partition 1020b after the factory reset is completed. In addition, the free partition in the system partition 1020a can also be used to temporarily store the hash value. The specific implementation process can refer to the description in the method 400 or the method 900, which will not be described here.
[0218] The wireless communication function of the electronic device 1000 can be implemented through the antenna 1, the antenna 2, the mobile communication module 1030, the wireless communication module 1040, the modem processor, and the baseband processor, etc.
[0219] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. The mobile communication module 1030 can provide a solution including 2G / 3G / 4G / 5G wireless communication applied to the electronic device 1000. The modem processor can include a modulator and a demodulator. The wireless communication module 1040 can provide a solution including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, etc. wireless communication solutions applied to the electronic device 1000.
[0220] As an example, the electronic device 1000 can connect to the cloud network through the wireless communication function provided by the antenna 1, the antenna 2, the mobile communication module 1030, the wireless communication module 1040, the modem processor, and the baseband processor to download model data to the user partition 1020b, or obtain a system upgrade package from a package server, and then perform a system upgrade operation.
[0221] The display screen 1060 is configured to display images, videos, and the like. The display screen 1060 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flex light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-OLED, a quantum dot light emitting diode (QLED), or the like. In some embodiments, the electronic device 1000 can include one or N display screens 1060, where N is a positive integer greater than 1.
[0222] In the scheme corresponding to the embodiments of the present application, the display screen 1060 can be used to display various user interfaces related to the factory reset process, such as the various user interfaces shown in Figure 1 Before performing the factory reset, if the electronic device 1000 detects that the data in the static partition A and the static partition B is inconsistent, and / or detects that the electronic device 1000 is currently performing system upgrade, the electronic device 1000 can also display prompt information through the display screen, the prompt information being used to prompt the user that the current system is being updated and the factory reset can be performed later, such as the prompt information 801 in Figure 6
[0223] The sensor 1050 is configured to collect various information such as environmental data and distance data. The sensor 1050 can include a touch sensor 1050a, a pressure sensor, a gyroscope sensor, a distance sensor, a temperature sensor, and various other types of sensors. The touch sensor 1050a can be disposed on the display screen 1060, and the touch sensor 1050a and the display screen 1060 form a touch screen, also referred to as a "touch screen". The touch sensor 1050a is configured to detect a touch operation acting on or near the touch sensor 1050a.
[0224] As an example, the electronic device 1000 detects an instruction input by a user to restore the factory settings through the touch sensor 1050a, and then performs the scheme provided by the embodiments of the present application. Referring to (c) in Figure 1 After the electronic device 1000 detects a clicking operation acting on the control 104 through the touch sensor 1050a, the electronic device 1000 performs the scheme provided by the embodiments of the present application.
[0225] The methods in the embodiments of the present application can be implemented in the electronic device 1000 with the hardware structure described above.
[0226] As to the hardware structure of the electronic device, it is understood that, Figure 8 The components included in the illustrated hardware structure do not constitute a specific limitation on the electronic device. The electronic device can have more or fewer components than those shown in the figure, can combine two or more components, or can have a different component configuration. The various components shown in the figure can be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application-specific integrated circuits.
[0227] The embodiments of the present application further provide a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the steps in each of the above method embodiments.
[0228] The embodiments of the present application provide a computer program product. When the computer program product is run on an apparatus, the apparatus is caused to implement the steps in each of the above method embodiments.
[0229] The embodiments of the present application provide a chip. The chip is used to execute instructions. When the chip is running, the technical solutions in the above embodiments are executed. The implementation principles and technical effects are similar, and will not be described here.
[0230] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transferred from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) The computer-readable storage medium can be any available medium accessible by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be magnetic media (such as floppy disk, hard disk, magnetic tape), optical media (such as high-density digital video disc (digital video disc, DWD)), or semiconductor media (such as solid state disk (solid state disk, SSD)) and the like.
[0231] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on such understanding, the present application can implement all or part of the processes in the above-mentioned embodiment methods, which can be completed by instructing related hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the above-mentioned various method embodiments can be implemented. The computer program includes computer program code, which can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium at least includes any entity or device capable of carrying the computer program code to the photographing device / electronic device, recording medium, computer memory, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), electrical carrier signal, telecommunication signal and software distribution medium. For example, U disk, mobile hard disk, magnetic disk or optical disk, etc. In some jurisdictions, according to legislation and patent practice, the computer-readable medium cannot be an electrical carrier signal and a telecommunication signal.
[0232] In the above-described embodiments, the description of each embodiment focuses on different aspects, and the parts not described in detail or recorded in a certain embodiment can be referred to the relevant description of other embodiments.
[0233] Those skilled in the art can understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0234] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the above-described device embodiments are only schematic, and the division of the units is only a logical function division, and there can be another division in actual implementation, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms.
[0235] It should be understood that the "embodiments" mentioned throughout the specification mean that the specific features, structures or characteristics related to the embodiments are included in at least one embodiment of the present application. Therefore, the various embodiments throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the execution order, and the execution order of the processes should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0236] The above-described embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalent; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
[0237] In addition, it needs to be explained that various numbers involved in the present application (such as the terms "first", "second", "third", "fourth" and other various term labels in the description and claims and the above-mentioned drawings (if any) and the like) are only for the convenience of description and do not limit the scope of the present application. The size of the serial number of each process does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic.
[0238] The terms "comprising" and "having" and any variations thereof mean "including but not limited to", unless otherwise specifically emphasized, for example, a process, method, system, product or device including a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0239] In the embodiments of the present application, the words "exemplarily" or "for example" and the like are used to represent as an example, illustration or description. Any embodiment or design scheme described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as more preferred or more advantageous than other embodiments or design schemes. Rather, the words "exemplarily" or "for example" and the like are intended to present the relevant concept in a specific manner.
[0240] In various embodiments of the present application, the terms and / or descriptions between different embodiments are consistent and can be referred to each other if there is no special description and logical conflict, and the technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationship. The specific operation method in the method embodiment of the present application can also be applied to the device embodiment or the system embodiment.
Claims
1. A method for restoring factory settings, characterized in that, The method is applied to an electronic device, the electronic device including a memory, the memory including a user partition, the method comprising: In response to triggering the electronic device to perform a factory reset operation, a backup partition is created from the user partition; Read the first system data from the user partition, write the first system data to the backup partition, and then perform a factory reset. After the factory reset is completed, the first system data is read from the backup partition and then rewritten to the user partition.
2. The method according to claim 1, characterized in that, Splitting a backup partition from the user partition includes: A backup partition of a preset size is cut off from the end of the user partition.
3. The method according to claim 1 or 2, characterized in that, The step of splitting the backup partition from the user partition includes: If the size of the first system data is greater than or equal to a preset threshold, a backup partition is split from the user partition.
4. The method according to claim 1 or 2, characterized in that, Before splitting the backup partition from the user partition, the method further includes: A hash value is calculated based on the first system data in the user partition, and the hash value is stored in the first sub-partition of the system partition of the memory. The first sub-partition is an idle partition in the system partition during the factory reset process. After splitting the backup partition from the user partition, the method further includes: The integrity of the first system data in the user partition is verified using the hash value. The integrity verification of the first system data has been confirmed to be successful.
5. The method according to claim 4, characterized in that, After rewriting the first system data to the user partition, the method further includes: The integrity of the first system data within the user partition is verified using the hash value. If the verification fails, format the user partition.
6. The method according to any one of claims 1 to 5, characterized in that, After rewriting the first system data into the user partition, the method further includes: The backup partition is merged into the user partition.
7. The method according to claim 6, characterized in that, Before merging the backup partition into the user partition, the method further includes: Format the backup partition.
8. The method according to claim 4, characterized in that, The system partition includes a first static partition and a second static partition. The operating system of the electronic device currently runs on the first static partition. The first subpartition includes one or more of the following subpartitions: Multiple sub-partitions in the second static partition, and the extended memory swap area in the system partition.
9. The method according to claim 8, characterized in that, If the backup partition includes the extended memory swap area, the method further includes, before writing the first system data to the backup partition: The first function is disabled, which is used to set the extended memory swap area as the running memory of the electronic device.
10. The method according to claim 8 or 9, characterized in that, Before splitting the backup partition from the user partition, the method further includes: It is determined that the data in the corresponding sub-partitions of the first static partition and the second static partition are consistent; and / or, It has been determined that the electronic device is not currently undergoing a system upgrade process.
11. The method according to claim 8 or 9, characterized in that, In the case where the first sub-partition includes the second sub-partition in the second static partition, after rewriting the first system data to the user partition, the method further includes: Copy the data from the third subpartition to the second subpartition. The third subpartition belongs to the first static partition and corresponds to the second subpartition.
12. An electronic device, characterized in that, The electronic device includes: one or more processors, and memory; The memory is coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the electronic device to perform the method as described in any one of claims 1 to 11.
13. A chip system, characterized in that, The chip system is applied to an electronic device, the chip system including one or more processors, the one or more processors being used to invoke computer instructions to cause the electronic device to perform the method as described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1 to 11.