Method for restoring factory settings and related equipment
By backing up system data to a free partition in the system partition before restoring it to the user partition, the issues of device overheating and lag 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, network lag, and system lag often occur, affecting the user experience.
Before restoring factory settings, back up system data to an unused partition in the system partition. After restoring factory settings, restore the data to the user partition to avoid increased network usage and power consumption.
It improves data recovery efficiency, reduces device overheating and network lag, and enhances user experience.
Smart Images

Figure CN121833341A_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, which is applied to an electronic device, and the electronic device includes a memory, the memory includes a user partition and a system partition, and the system partition includes a first sub-partition. Specifically, the method includes: in response to triggering the electronic device to execute the operation of restoring factory settings, the electronic device backs up first system data in the user partition to the first sub-partition, and after completing the backup, the operation of restoring factory settings is executed again. After completing the operation of restoring factory settings, the electronic device restores the first system data from the first sub-partition to 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 functions (such as AI function) are affected, or the smoothness 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, the first sub-partition is an idle partition in the system partition during the process of performing the factory reset, that is, the scheme of the present application uses the idle partition in the system partition to backup the first system data, which not only backs up the data, but also does not affect the process of the factory reset. At the same time, the system partition is a relatively stable partition, and using the idle partition in the system partition to backup data can improve the reliability of data.
[0009] In a possible implementation manner of the first aspect, the first system data includes model data and / or optimization data.
[0010] For the case that the first system data includes model data: if the electronic device re-downloads the model data from the cloud after completing the factory reset, it may occupy the network of the electronic device, resulting in network lag, and may also cause the power consumption of the electronic device to increase. By the scheme provided in the present application, the model data can be directly restored from the backup partition (i.e. the first sub-partition) to the user partition after the factory reset is completed, which can avoid the network occupation.
[0011] For the case that the first system data includes optimization data: if the electronic device re-compiles the optimization data by using a local compiler after completing the factory reset, it may cause the power consumption of the device to increase and the device to heat seriously, thereby affecting the smoothness of the system. By the scheme provided in the present application, the optimization data can be directly restored from the backup partition (i.e. the first sub-partition) to the user partition after the factory reset is completed, which can reduce the power consumption and heating of the device.
[0012] 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, and the first sub-partition includes one or more of the following sub-partitions: a plurality of sub-partitions in the second static partition, an extended memory swap area in the system partition.
[0013] In the above scheme, any one or more sub-partitions in the second static partition can be used as the backup partition (i.e., 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 data in the first static partition. Therefore, the second static partition does not participate in the process of restoring the factory settings, and thus a sub-partition in the second static partition can be used as the backup partition.
[0014] In the above scheme, the extended memory swap area can also be used as the backup partition (i.e., the first sub-partition). The extended memory swap area is used to support the "smart memory" function. Therefore, even if the extended memory swap area is used as the data backup, at most, the system running space is temporarily reduced, and the system operation is not affected. Compared with the benefits obtained by the scheme of the present application, the impact of the reduced running space can be ignored.
[0015] In a possible implementation of the first aspect, in the case where the first sub-partition includes the extended memory swap area, before the first system data is written into the first sub-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.
[0016] In the above scheme, if the extended memory swap area is to be used as the backup partition, the first function (i.e., the "smart memory" function) can be temporarily turned off, so that the backup data in the extended memory swap area is not overwritten by other newly written data.
[0017] In a possible implementation of the first aspect, before the first system data is read from the user partition and written into the first sub-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.
[0018] In the above scheme, if a sub-partition in the second static partition is to be used as the backup partition, the use of the second static partition can be detected before the data backup is performed. The detection can be performed by detecting whether the data in the corresponding sub-partitions in the first static partition and the second static partition are consistent, or by detecting 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 as the backup partition, so that the conflict of data in the backup partition is prevented, and the system failure is avoided.
[0019] In a possible implementation of the first aspect, in a case where the first sub-partition comprises a second sub-partition in the second static partition, after the first system data is re-written to the user partition, the method further comprises: copying 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.
[0020] In a case where the first sub-partition comprises a sub-partition in the second static partition (such as the second sub-partition), after the first system data is re-written to 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, thereby improving the stability of the system.
[0021] In a possible implementation of the first aspect, reading the first system data from the user partition and writing the first system data to the first sub-partition comprises: in a case where a size of the first system data is less than or equal to a preset threshold, reading the first system data from the user partition and writing the first system data to the first sub-partition.
[0022] Exemplarily, since the system partition has a limited space size, the free partition in the system partition is usually not large, and therefore the scheme provided in the embodiments of the present application is mainly applicable to a case where the amount of data to be backed up is relatively small. Therefore, a threshold (hereinafter referred to as a preset threshold) can be set, and the scheme provided in the present application is executed only when the data to be backed up (i.e., the first system data) is less than the preset threshold, thereby avoiding a case where the backup partition (i.e., the first sub-partition) cannot carry the backup data (i.e., the first system data).
[0023] In a possible implementation of the first aspect, after the first system data is read from the user partition, the method further comprises: recording a data length of the first system data; and reading the first system data from the first sub-partition comprises: reading the first system data from the first sub-partition according to the data length.
[0024] In the above scheme, by recording the data length of the backup data (i.e., the first system data), the backup data can be read more correctly in the data recovery process.
[0025] In a possible implementation manner of the first aspect, the first sub-partition includes a second sub-partition and a third sub-partition, the first system data includes second system data and third system data, and reading the first system data from the user partition and writing the first system data into the first sub-partition includes: reading the second system data and the third system data from the user partition in sequence, and then writing the second system data and the third system data into the second sub-partition and the third sub-partition respectively; the method further includes: storing sequence information, the sequence information being used to indicate the sequence in which the electronic device reads the second system data and the third system data from the user partition; and re-writing the first system data into the user partition includes: re-writing the third system data and the second system data into the user partition in sequence based on the sequence information.
[0026] In the above scheme, by recording the reading sequence of different backup data (i.e., the second system data and the third system data), the backup data can be re-written into the user partition in sequence in the data recovery process, so as to accurately recover the backup data.
[0027] In a possible implementation manner of the first aspect, before performing the factory reset, the method further includes: calculating a hash value according to the first system data, and storing the hash value in a fourth sub-partition in the system partition, the fourth sub-partition being an idle partition in the system partition in the process of performing the factory reset; and after re-writing the first system data into 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 in the case of verification failure, clearing the data in the first sub-partition.
[0028] In the above scheme, after the backup data (i.e., the first system data) is restored to the user partition, the integrity of the data can be verified by using the hash value. If the integrity verification of the data fails, the data should be discarded (i.e., the user partition is re-cleared), so as to avoid the case that the subsequent system runs incorrectly due to incomplete data.
[0029] In a possible implementation manner of the first aspect, before verifying the integrity of the first system data in the user partition by using the hash value, the method further includes: reading the hash value from the fourth sub-partition according to the data length of the hash value.
[0030] In the above scheme, the hash value can be more accurately read from the fourth sub-partition according to the length of the hash value. The length of the hash value is determined by a hash algorithm used to calculate the hash value.
[0031] In a possible implementation manner of the first aspect, the fourth sub-partition does not belong to the first sub-partition.
[0032] In a possible implementation, the fourth sub-partition does not belong to the first sub-partition, that is, the fourth sub-partition is used for storing the hash value exclusively, and is not used for data backup, so that the hash value and the first system data can be read correctly subsequently.
[0033] In a second aspect, an electronic device is provided, including a memory and a processor, the memory storing a computer program executable on the processor, and the processor executes the computer program to implement the steps of the method according to any one of the first aspect.
[0034] 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.
[0035] In a fourth aspect, a computer program product is provided, and when the computer program product is executed on an electronic device, the electronic device executes the method according to any one of the first aspect.
[0036] In a fifth aspect, a chip system is provided, including 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.
[0037] The chip system can be a single chip or a chip module composed of multiple chips.
[0038] It can 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
[0039] Figure 1 A user interface diagram of an application scenario to which the embodiments of the present application are applicable is shown;
[0040] Figure 2 A storage architecture diagram of a memory provided by the embodiments of the present application is shown;
[0041] Figure 3 A data change process diagram in a memory provided by the embodiments of the present application is shown;
[0042] Figure 4 An exemplary flowchart of the method 400 provided by the embodiments of the present application is shown;
[0043] Figure 5 An exemplary flowchart of the method 500 to the method 700 provided by the embodiments of the present application is shown;
[0044] Figure 6A user interface diagram provided by an embodiment of the present application is shown.
[0045] Figure 7 An exemplary block diagram of the method 900 provided by an embodiment of the present application is shown.
[0046] Figure 8 A hardware architecture diagram of an electronic device provided by an embodiment of the present application is shown. DETAILED DESCRIPTION
[0047] 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.
[0048] 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 that controls and manages 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.
[0049] In the process of using the electronic device, the user may, for example, perform a factory reset operation on the operating system when the user encounters a situation of operating system lag or insufficient storage space, or when the user sells the electronic device before considering privacy protection. The user may perform a factory reset operation on the electronic device to clear user data stored on the electronic device.
[0050] 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.
[0051] Figure 1 A possible user interface when the electronic device performs a factory reset is shown. In Figure 1 In the embodiments of the present application, the electronic device is taken as a mobile phone for example.
[0052] Figure 1 Image (a) shows a user interface 100a, which displays icons for multiple applications. These applications include one or more system applications (such as settings, camera, phone, etc.) and one or more third-party applications (such as lifestyle, shopping, etc.). System applications typically refer to applications pre-installed in the phone's operating system. They are installed along with the operating system to provide the phone with a basic operating environment and functional support. These applications are usually directly integrated into the system firmware by the device manufacturer or operating system provider, and users typically cannot uninstall them. Third-party applications, on the other hand, are applications developed by third-party software developers independent of the operating system developer. These third-party applications on a phone can be downloaded and installed by the user through an app store during phone use, or they can be pre-installed during (or after) the operating system installation. Such pre-installed third-party applications are called pre-installed applications. In one possible example, the phone's operating system installation package carries installation packages for one or more pre-installed applications. During the operating system installation process, the pre-installed application data packages are written to a preset partition in the phone's memory. After the operating system installation is complete, the phone restarts to make the operating system effective, and during the restart process, the phone can automatically install the pre-installed applications. In other words, pre-installed apps are automatically installed on the phone along with the operating system. Therefore, when an electronic device installs a new operating system, upgrades an existing operating system, or performs a factory reset, the pre-installed apps will be automatically installed.
[0053] See Figure 1 Gesture ① in (a): In response to clicking the icon 101 of the "Settings" app, the electronic device opens the "Settings" app and displays as shown in the image. Figure 1 User interface 100b is shown in (b) above. It is understood that user interface 100b is merely a function interface within the "Settings" application, and is not necessarily the default interface for the settings application. Figure 1 (b) in the example is merely an illustration. Figure 1 As shown in (b), the user interface 100b includes multiple function controls, including a "Factory Reset" function control. It is understood that the "Factory Reset" displayed on the user interface 100b may also be other text and / or icon instructions such as "Factory Reset," "Format Phone," or "Factory Reset Operation" used to instruct the first electronic device to perform a factory reset.
[0054] See Figure 1 Gesture ② in (b): In response to clicking the "Factory Reset" function control 102, the phone jumps to the following... 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.
[0055] Referring to Figure 1 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 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. The present application does not limit this.
[0056] 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 a 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.
[0057] 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.
[0058] After the factory reset is completed, the phone automatically restarts to make the operating system take effect again. At the same time, the phone automatically installs pre-installed applications (if any) during the restart.
[0059] 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. These 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).
[0060] It is 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 reinstalled are the system applications and the pre-installed applications. It is also understood that the plurality of applications in the user interface 100f are arranged in a preset order.
[0061] The above takes the electronic device as a mobile phone as an example, and details the change process of the user interface when the electronic device performs factory reset. The following describes a possible change process of the storage space when the electronic device performs factory reset. Figure 2 and Figure 3 The following describes a possible change process of the storage space when the electronic device performs factory reset.
[0062] The electronic device is usually provided with a memory, and the operating system, user data and other data information of the electronic device can be stored in the memory. The present application does not limit the storage structure of the memory in the electronic device, and the following describes a possible storage structure of the memory of the electronic device by taking Figure 2 as an example. It should be understood that Figure 2 The examples in the present application take the memory adopting a virtual Virtual A / B partition structure as an example for illustration, but the present application is not limited thereto, i.e., the memory of the electronic device in the present application can also adopt other types of data storage structures, such as a Full A / B partition structure.
[0063] The following describes the memory partition structure shown in Figure 2 by taking an electronic device installed with an Android operating system as an example. The memory of the electronic device includes a system partition (System) and a user partition (Data).
[0064] Firstly, the system partition is described: the system partition can also be referred to as a system data partition, a system space, etc., and is used to store system data related to the operating system of the electronic device. It can be understood that the system data stored in the system partition is read-only data, and the system data in the system partition will not change unless a system upgrade or a system-level modification such as flashing is performed. For convenience, the read-only system data stored in the system partition is denoted as system data A in the present application.
[0065] The system partition includes a dynamic partition (Super) and a static partition. The dynamic partition is usually used to store system running programs. The static partition includes a static partition A (slot_A, which can also be referred to as a first static partition) and a static partition B (slot_B, which can also be referred to as a second static partition). The static partition A and the static partition B can each include multiple sub-partitions, such as a boot sub-partition, a modem sub-partition, etc.
[0066] 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 illustration, 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.
[0067] 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.
[0068] 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.
[0069] 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.
[0070] 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, which refers to application programs (APPs) installed by a user personally, pictures, documents, and videos saved by the user personally, and the like.
[0071] In this embodiment, a portion of system data can also be stored in a 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 rather modifiable data. The system can generate or update the system data in the user partition as needed. For convenience, this 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, storage space in the system partition can be saved, and system data B can be optimized and updated according to actual needs.
[0072] This application does not limit the type of data within system data B. It should be understood that, depending on actual business needs, various types of modifiable system data can be stored in the user partition. The following provides illustrative examples of two possible types of data within system data B.
[0073] As an example, system data B includes model data and / or optimization data.
[0074] Here, model data refers to resource-type model files, which are the foundational data for artificial intelligence models. In other words, model data is used to support electronic devices in processing data through artificial intelligence models (such as neural network models used for facial recognition).
[0075] Understandably, model data may also be stored in the system partition. This model data is typically stored in the dynamic partition during operating system installation. Since the data in the system partition is read-only, it cannot be modified. 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 an electronic device leaves the factory, its system partition stores model data for version 5.0.1 of the large model. After some time, the developers release version 5.0.2 of the large model in the cloud. The new version improves model performance. To allow users to experience the features of the new version, the electronic device can download the model data for version 5.0.2 from the cloud to the user partition. When using it, the electronic device can choose to use the higher version of the large model data from either the system partition or the user partition.
[0076] 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 starting 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.
[0077] 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.
[0078] 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.
[0079] It can be understood that, Figure 2 It can be understood that,
[0080] In a possible implementation, a partition table can be provided in the memory, and the partition table 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.
[0081] Table 1
[0082]
[0083] 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. From the foregoing, it can be seen that 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 smoothness 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 make the electronic device 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.
[0084] 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, refer to the corresponding description of the (a) in FIG. 1). Figure 1 The memory of the electronic device currently stores the system data B, which is taken as an example that the system data B includes model data and optimization data in the (a) of FIG. 1. Figure 3 In the (a) of 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) of 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.
[0085] 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, refer to the corresponding description of the (e) in FIG. 1). Figure 1 As shown in the (b) of FIG. 1, after the completion of the factory settings, the model data and the optimization data in the user partition have been cleared. Figure 3
[0086] Figure 3 (c) of FIG. 10 shows a memory architecture of the electronic device after the electronic device is restarted, at which time the electronic device has completed the operations of restoring factory settings and restarting. As an example, the electronic device can currently display the user interface 100f (see the description of the user interface 100f in (f) of FIG. 10). During the process of restarting the electronic device and / or after the electronic device is restarted, the electronic device can automatically obtain the model data and the optimization data, for example, the electronic device re-downloads the model data from the cloud and re-compiles the calculation to obtain the optimization data by using the local compiler. The electronic device can obtain part of the system data B (e.g., high-priority data that can affect the operation of the system) during the process of restarting, and obtain the remaining data after the restarting is completed. Figure 1 (f) of FIG. 10). During the process of restarting the electronic device and / or after the electronic device is restarted, the electronic device can automatically obtain the model data and the optimization data, for example, the electronic device re-downloads the model data from the cloud and re-compiles the calculation to obtain the optimization data by using the local compiler. The electronic device can obtain part of the system data B (e.g., high-priority data that can affect the operation of the system) during the process of restarting, and obtain the remaining data after the restarting is completed.
[0087] Therefore, by the scheme shown in Figure 3 FIG. 10, although the electronic device clears the system data B stored in the user partition during the process of restoring factory settings, after the electronic device restores factory settings, the electronic device can automatically obtain the system data B and store the re-obtained system data B in the user partition. By this scheme, the situation that part of the system functions of the electronic device (e.g., AI functions) cannot be used or the system and software run slowly due to the missing system data B can be reduced.
[0088] However, the above scheme can cause the electronic device to have problems such as serious device heating, phone running slowly, network running slowly, 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 system data B (e.g., generates part of the optimization data by compiling) during the process of restarting after the electronic device restores factory settings, the time of restarting will be longer, which makes the user wait for a longer time, affecting the user experience. For another example, the electronic device connects to the network to download the model data from the cloud after the restarting is completed. Since the model data is usually large (e.g., 4 G), the time of downloading is also long, which occupies the network of the electronic device for a long time, which can cause the network to run slowly when the user uses other network services. For another example, the electronic device generates the optimization data by using the local compiler after the restarting is completed, which makes the power consumption of the electronic device higher and the heating more, which can affect the fluency of the overall operation of the electronic device.
[0089] In view of the above problems, the embodiments of the present application provide a method for restoring factory settings, in which part of the system partition can be selected as a backup partition, and the system data C (part or all of the system data B) in the system partition is temporarily stored in the backup 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, thereby improving the efficiency of data recovery, avoiding the occupation of the network during the process of restoring the system data C, and reducing the power consumption and heat generation of the electronic device during the process.
[0090] The backup partition in the embodiments of the present application can refer to an idle partition in the system partition in the scenario of restoring factory settings, such as a partition (i.e., a non-running partition) for backup in the static partition, or a single partition (such as an extended memory swap area) that is not required to be used in the scenario of restoring factory settings. The following will be described in combination with the method 400 in the embodiments of the present application. Figure 4
[0091] S401a, the electronic device stores the system data #1 in the system data B to the extended memory swap area.
[0092] S401b, the electronic device stores the system data #2 in the system data B to the modem_b.
[0093] Exemplarily, in the method 400, the extended memory swap area and the static partition B are taken as the backup partitions, wherein the static partition B is a non-running partition, that is, the current system is not running in the static partition B, but running in the static partition A, and therefore the static partition B can be regarded as an idle partition at present.
[0094] It can be understood that the method 400 is described by taking the extended memory swap area and the static partition B as the backup partitions as an example, but the present application is not limited thereto. In some embodiments, other idle partitions in addition to the extended memory swap area and the static partition B can also be taken as the backup partitions; in other embodiments, only one partition can be taken as the backup partition; and in still other embodiments, three or more partitions can be taken as the backup partitions.
[0095] It can also be understood that, in the case of taking the static partition B as the backup partition, all sub-partitions in the static partition B can be used as the backup partition, or only part of the sub-partitions in the static partition B can be used as the backup partition, for example, modem_b and / or init_boot_b in the static partition B are used as the backup partition, or n (n is a positive integer) sub-partitions with the largest storage space in the static partition B are used as the backup partition, and the present application does not limit this. In the method 400, modem_b in the static partition B is taken as the backup partition as an example.
[0096] After the electronic device receives the instruction indicating that the electronic device performs the factory reset recovery, and before the operation of performing the factory reset recovery is performed, the electronic device respectively stores the system data #1 and the system data #2 to the extended memory swap area and the modem_b. In a specific example, the electronic device finds and copies the system data #1 from the user partition, and then writes the system data #1 to the extended memory swap area in blocks; similarly, the electronic device finds and copies the system data #2 from the user partition, and writes the system data #2 to the modem_b in blocks.
[0097] It can be understood that the electronic device can also directly migrate the system data #1 and the system data #2 to the extended memory swap area and the modem_b respectively, that is, the electronic device can delete the system data #1 and the system data #2 in the original user partition while backing up the system data #1 and the system data #2, which can improve the speed of subsequent formatting of the user partition.
[0098] It can also be understood that, since the extended memory swap area is originally used to support the "smart memory" function, the "smart memory" function can be turned off before the system data #1 is written to the extended memory swap area, so as to prevent other data from "polluting" the system data #1 in the extended memory swap area subsequently.
[0099] In one possible implementation, when the electronic device writes system data #1 to the extended memory swap area, it can directly overwrite the existing data in the extended memory swap area with system data #1. Optionally, in this implementation, the electronic device can record the data length (e.g., number of bytes) of system data #1, or record the specific storage location of system data #1 in the extended memory swap area (e.g., start and end addresses), so as to correctly read system data #1 later. Similarly, when the electronic device writes system data #2 to modem_b, it can directly overwrite the existing data in modem_b with system data #2. Optionally, in this implementation, the electronic device can record the data length of system data #2, or record the specific storage location of system data #2 in modem_b, so as to correctly read system data #2 later.
[0100] In another possible implementation, before writing system data #1 to the extended memory swap area, the electronic device can first format the extended memory swap area (i.e., clear all data in the extended memory swap area), and then write system data #1 to the extended memory swap area. In this implementation, the data length of system data #1 or its specific storage location in the extended memory swap area does not need to be recorded, because after writing system data #1 to the extended memory swap area, the extended memory swap area only stores system data #1. During the subsequent process of restoring system data #1 to the user partition (refer to subsequent step S403a), all data in the extended memory swap area can be read directly. Similarly, before writing system data #2 to modem_b, the electronic device can first format modem_b (i.e., clear all data in modem_b), and then write system data #2 to modem_b. In this implementation, it is not necessary to record the data length of system data #2 or the specific storage location of system data #2 in modem_b. This is because after writing system data #2 to modem_b, modem_b only stores system data #2. During the subsequent process of restoring system data #2 to the user partition (refer to subsequent step S403b), all data in modem_b can be read directly.
[0101] It can be understood that the system data #1 and the system data #2 are to-be-backed-up data in the system data B, and the to-be-backed-up data can be all data in the system data B or part of the data in the system data B. For convenience, the to-be-backed-up data in the system data B is referred to as system data C in the embodiments of the present application, that is, the system data C can be understood as the combination of the system data #1 and the system data #2. Specifically, the system data #1 can include only part of the data in the system data B or all the data in the system data B; similarly, the system data #2 can include only part of the data in the system data B or all the data in the system data B; the system data #1 and the system data #2 can be the same or different; in the case that the system data #1 and the system data #2 are different, the system data #1 and the system data #2 can have an intersection or can have no intersection. As an example, the system data #1 is model data in the system data B, and the system data #2 is optimization data in the system data B; as another example, the system data #1 is model data and optimization data in the system data B, and the system data #2 is also model data and optimization data in the system data B, that is, the scheme provided in this example can perform repeated backup on the system data C, and if the integrity verification of one of the backup data fails in the subsequent process, the other backup data can be used; as another example, the system data #1 is the first x bytes of data in the system data C, and the system data #2 is other data in the system data C.
[0102] Optionally, in the case that the system data #1 and the system data #2 are different, the electronic device can also record the order of reading the system data #1 and the system data #2 from the user partition (i.e., the execution order of steps S401a and S401b) so as to correctly restore the system data #1 and the system data #2 to the user partition later. For example, the electronic device reads the system data #1 from the user partition first, and then reads the system data #2 from the user partition (i.e., the system data #1 is stored first and the system data #2 is stored later in the user partition), and the electronic device can record the order information indicating the order of reading the system data #1 and the system data #2. When performing data recovery later, the electronic device can restore the system data #2 first and then restore the system data #1 according to the order information (for details, refer to the description of steps S403a and S403b below), so as to correctly restore the system data C.
[0103] Based on the above description, it can be known that the application does not limit the specific content of data backup, and the electronic device can backup all data in the system data B or only backup part of the data in the system data B. Meanwhile, the application does not limit the backup mode, and different contents can be respectively backed up in different backup partitions, or the same content can be repeatedly backed up in multiple backup partitions.
[0104] In summary, before performing the factory reset (i.e., before formatting the user partition), the electronic device backs up part or all of the data (i.e., system data C) in the system data B by using the backup partition (such as the extended memory swap and modem_b).
[0105] In a possible implementation, the electronic device can determine one or more of the following according to the configuration file: backup content, backup partition, and backup mode. The backup content is used to indicate which data in the system data B needs to be backed up by the electronic device, that is, the backup content refers to the data (represented by system data C in the application) in the system data B that needs to be backed up. The backup partition is used to indicate which partition (for example, the extended memory swap and modem_b in the application) the backup content needs to be backed up to by the electronic device. The backup mode is used to indicate how the backup content is backed up to the backup partition by the electronic device, or which data in the backup content is backed up to which partition by the electronic device. The following will be exemplarily described.
[0106] In an example (denoted as example A), the configuration file includes information of the data to be backed up, so that the electronic device can determine the backup content (i.e., the system data C) according to the configuration file.
[0107] Optionally, in example A, after determining to backup the system data C according to the configuration file, the electronic device can determine the size of the system data C. In the case that the size of the system data C is less than or equal to a preset threshold (such as 3G), the electronic device determines to backup the system data C by using the free partition (i.e., the backup partition described in the application) in the system partition, i.e., to perform the above steps S401a and S401b. In the case that the size of the system data C is greater than the preset threshold, the electronic device determines to backup the system data C by dividing part of the space in the user partition, and the specific implementation is not limited in the application.
[0108] Optionally, in example A, the electronic device can backup the system data according to a preset policy. For example, according to the preset policy, the electronic device first backups the system data C to the extended memory swap area, and then stores the remaining data in the system data C to the modem_b when the extended memory swap area is full (or the remaining space of the extended memory swap area is less than or equal to a preset size). For another example, according to the preset policy, the electronic device backups half of the system data C to the extended memory swap area and the other half to the modem_b. For another example, according to the preset policy, the electronic device reads data of a preset length from the system data C and backups the data to the extended memory swap area, and then backups the remaining data to the modem_b. It can be understood that the above-mentioned preset policy can be pre-stored in the electronic device or carried in the configuration file, and the present application does not limit this.
[0109] In another example (denoted as example B), the configuration file includes the association relationship between different data in the system data C and different partitions, and the electronic device can directly store different data to be backed up to the corresponding partitions according to the configuration file. For example, the configuration file includes the association relationship between system data #1 and the extended memory swap area, and the association relationship between system data #2 and the modem_b, and the electronic device directly backups the system data #1 to the extended memory swap area and the system data #2 to the modem_b according to the configuration file.
[0110] In another example (denoted as example C), the configuration file includes priority information of different data in the system data C, and the electronic device can backup the data with high priority in the system data C to the free partition in the system partition (i.e. the backup partition described in the present application) according to the configuration file, and store the data with low priority to the space divided from the user partition. For example, the priority information included in the configuration file is as follows (arranged in order of priority from high to low): system data #1, system data #2, system data #3, and the electronic device backups the system data #1 to the extended memory swap area, the system data #2 to the modem_b, and the system data #3 to the space divided from the user partition according to the configuration file (the specific implementation manner is not limited in the present application). For another example, the priority information included in the configuration file is as follows (arranged in order of priority from high to low): system data #1, system data #2, system data #3, and the electronic device sequentially backups different data in the system data C in order of priority from high to low, and in the process of backup, the electronic device first backups to the backup partition (such as the extended memory swap area and the modem_b) in the system partition, and then backups the remaining data to be backed up to the space divided from the user partition for backup when the backup partition is full (or the remaining space of the backup partition is less than or equal to a preset size).
[0111] It can be understood that the above configuration file can be pre-configured in the product assembly of the electronic device.
[0112] In summary, based on the above steps S401a and S401b, the electronic device stores the system data C in the backup partition in the system partition in advance before performing the factory reset.
[0113] Optionally, S401c, the hash value is calculated and stored to boot_b.
[0114] Exemplarily, in order to improve the reliability of the data, the hash value of the data to be backed up can be calculated before performing the factory reset, so that the integrity of the backup data can be verified by using the hash value subsequently, which can be referred to the description of step S404 for details, which will not be repeated here.
[0115] It can be understood that the above hash value can be one or more values, that is, the electronic device can use all the data to be backed up (that is, the system data C) to calculate a hash value, or can calculate a plurality of hash values for the data in different backup partitions. For example, the electronic device calculates hash value #1 by calculating system data #1, and calculates hash value #2 by calculating system data #2.
[0116] After the electronic device calculates the hash value, the hash value can be stored in a free partition of the system partition (this embodiment takes boot_b as an example). It can be understood that the free partition for storing the hash value and the free partition for storing the backup data can be the same or different, which is not limited in the present application.
[0117] In one possible implementation, when the electronic device writes the hash value into boot_b, the hash value can be directly used to overwrite the original data in boot_b. 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.
[0118] It can be understood that the present application does not limit the order of execution of steps S401a, S401b, S401c.
[0119] S402, the electronic device clears the data in the user partition.
[0120] Exemplarily, after completing the above steps S401a-S401c, the electronic device performs the factory reset. In the process of performing the factory reset, the electronic device clears the data in the user partition, which includes the system data B.
[0121] S403a, the electronic device rewrites the system data #1 to the user partition.
[0122] S403b, the electronic device rewrites the system data #2 to the user partition.
[0123] Exemplarily, after the factory setting recovery is completed, the electronic device re-recoveries the system data C from the backup partition to the user partition.
[0124] In a possible implementation, if the electronic device records the sequence information in advance (i.e., the electronic device reads the system data #1 and the system data #2 in step S401a and step S402 in sequence), the electronic device can determine the sequence of writing the system data #1 and the system data #2 to the user partition according to the sequence information. For example, the sequence information indicates that the electronic device reads the system data #1 from the user partition first and then reads the system data #2 from the user partition when the data backup is performed (i.e., the system data #1 is stored in front and the system data #2 is stored in back in the user partition), and the electronic device can copy the system data #2 from the modem_b according to the sequence information, and write the system data #2 to the user partition in block, then copy the system data #1 from the extended memory swap area, and write the system data #1 to the user partition in block, so as to correctly restore the system data C in the user partition.
[0125] In a possible implementation, if the electronic device records the data length of the system data #1 in advance, the electronic device can read the system data #1 from the extended memory swap area based on the data length, and then copy the system data #1 to the user partition. Similarly, if the electronic device records the data length of the system data #2 in advance, the electronic device can read the system data #2 from the modem_b based on the data length, and then copy the system data #2 to the user partition.
[0126] It can be understood that the step S403a and the step S403b can be executed in the process of restarting the electronic device, or can be executed after the restarting of the electronic device is completed, and the present application does not limit this.
[0127] Optionally, S404, the electronic device checks the integrity of the data by the hash value.
[0128] Exemplarily, 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.
[0129] 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.
[0130] In a possible implementation, if only one hash value is stored in the boot_b, it means that the hash value is calculated by the system data C, and the electronic device can calculate a new hash value by using the recovered system data C in the user partition. If the hash value stored in the boot_b is the same as the hash value calculated by the electronic device, the data integrity verification is passed, and the electronic device continues to execute the subsequent process, otherwise the electronic device re-clears the user partition.
[0131] In another possible implementation, if only two hash values are stored in the boot_b, it means that the two hash values are calculated by the system data #1 and the system data #2 respectively, so the electronic device can verify the integrity of the system data #1 and the system data #2 by using the two hash values respectively. If the integrity verification of the system data #1 and the system data #2 is passed, the electronic device continues to execute the subsequent process, otherwise the electronic device re-clears the user partition.
[0132] S405a, the electronic device copies the data in the modem_a to the modem_b.
[0133] S405b, the electronic device copies the data in the boot_a to the boot_b.
[0134] Exemplarily, after the electronic device re-recovering the system data C to the user partition, it is also necessary to re-recover the data in the modem_b and the boot_b. As described above, the static partition A and the static partition B are backups of each other, and the data in the corresponding sub-partitions in the static partition A and the static partition B are originally consistent, so in order to recover the data in the modem_b and the boot_b, the data in the modem_a can be copied to the modem_b, and the data in the boot_a can be copied to the boot_b.
[0135] Optionally, after the electronic device re-recovering the system data C to the user partition, it can also re-enable the "smart memory" function. It can be understood that the electronic device can not need to recover the data in the extended memory swap area, because the extended memory swap area is originally a temporary data area, so it does not need to recover the data therein. Of course, the electronic device can also clear the data (i.e. system data #1) in the extended memory swap area.
[0136] In summary, in the method 400 provided in the embodiments of the present application, a part of the system partitions of the electronic device is selected as a backup partition for backing up the system data C stored in the user partition. After the electronic device performs the factory reset, the system data C in the user partition is cleared. If the electronic device reacquires the system data C by means of cloud downloading and / or local compiling, the electronic device may have serious heating, network lag, and unsmooth system, etc. In the scheme 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 data recovery efficiency, avoid the network occupation in the process of restoring the system data C, and reduce the power consumption and heating of the electronic device in the process.
[0137] In the method 400 described above, one of the static partition A and the static partition B can be used as a backup partition for temporarily backing up the system data C, because the static partition A and the static partition B are mutually backed up, the data in the two partitions are consistent, and the operating system of the electronic device only runs in one of the static partitions, so the other static partition is in an idle state (i.e., an unrunning state). Therefore, even if the static partition is used as a backup partition, it will not affect the factory reset process.
[0138] However, the data in the static partition A and the 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 causes the data in the two static partitions to be inconsistent. The following is an exemplary description.
[0139] Suppose that the current operating system runs in the 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), which includes 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.
[0140] It can be understood that version 2 can be the operating system version that the electronic device needs to reach after upgrading, can be the version of the latest released operating system, or can be the user-specified rollback operating system version, which is not limited in the present application. Of course, different upgrade data packages are needed for upgrading to different operating system versions.
[0141] After obtaining the upgrade package and passing the verification on the upgrade package, an update engine in the electronic device can write the static partition upgrade data in the upgrade package into the static partition B, specifically, write the upgrade data in the boot sub-partition in the upgrade package into boot_b, write the upgrade data in the modem sub-partition in the upgrade package into modem_b, and so on. That is, if the operating system of the electronic device is currently running in the static partition A, during the system upgrade, the update engine writes the static partition upgrade data in the upgrade package into the static partition B. Since the data in the static partition A and the static partition B is originally consistent, after the static partition upgrade data is written into the static partition B, before the system upgrade is started and completed, the data in the static partition A and the static partition B will be inconsistent.
[0142] During the process of writing data into the static partition B, the static partition B can no longer be regarded as a free partition. In this case, the execution of the factory reset can be paused, and a response prompt information can be displayed to the user. The following describes the three possible solutions in combination with Figure 5 The three possible solutions are exemplarily described.
[0143] Figure 5 (a) in FIG. 5 shows an exemplary flowchart of the method 500a provided by the embodiments of the present application. The following exemplarily describes the specific implementation process of the method 500a.
[0144] S501, the electronic device receives an instruction indicating that the electronic device performs the factory reset.
[0145] S502, the electronic device calculates the hash values of the corresponding sub-partitions in the static partition A and the static partition B.
[0146] Exemplarily, after receiving the instruction indicating that the electronic device performs 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 Figure 1 (c) in FIG. 5, 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, specifically, 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.
[0147] S503, the electronic device determines that the hash values of any one group of sub-partitions are different.
[0148] Exemplarily, a group of sub-partitions in the embodiments of the present application refers to a group of 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.
[0149] 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.
[0150] S504, the electronic device displays prompt information.
[0151] 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 are always consistent, therefore, 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, prompting the user to perform the factory reset later, such as the prompt information 801 shown in Figure 6
[0152] S505, the electronic device continues to perform the method 400.
[0153] Exemplarily, if the data in all corresponding sub-partitions in the static partition A and the static partition B are consistent, it means that the electronic device is not currently in the system upgrade process, therefore, one of the static partition B and the static partition A is currently an idle partition, which 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.
[0154] Figure 5 (b) of FIG. 6 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.
[0155] S601, the electronic device receives an instruction indicating that the electronic device performs the factory reset.
[0156] S602, the electronic device judges whether the current is in the system upgrade process.
[0157] Exemplarily, after receiving the instruction indicating that the electronic device performs the factory reset, the electronic device judges whether the current is in the system upgrade process. For example, referring to Figure 1 (c) of FIG. 6, the electronic device judges whether the current is in the system upgrade process after detecting the click operation on the control 104.
[0158] The present application does not limit the specific implementation of the electronic device determining whether it is in the system upgrade process. In an example, the electronic device determines whether the " / data / gsi / ota" path in the memory is empty. If the path is empty, it indicates that the electronic device is not currently in the system upgrade process. If the path is not empty, it indicates that the electronic device is currently in the system upgrade process. It can be understood that during the system upgrade process, the electronic device will write a cache file to the " / data / gsi / ota" path, so whether the path is empty can be used to determine whether the system upgrade process is currently in progress.
[0159] S603, the electronic device displays prompt information.
[0160] For example, if the system is currently running in static partition A, during the system upgrade process, upgrade data will be written to static partition B. At this time, static partition B cannot be used as a backup partition, so 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, as shown in prompt information 801 in FIG. 8. Figure 6
[0161] S604, the electronic device continues to execute method 400.
[0162] For example, if the electronic device is not currently in the 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, so the electronic device can continue to execute method 400. That is, method 600 can be executed before method 400.
[0163] It can be understood that in some special scenarios, even if the system is not in the system upgrade process, the data in the static partition A and the static partition B can be different, so 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 a backup partition. That is, compared with method 500, method 600 can adapt to more application scenarios.
[0164] Figure 5 (c) of FIG. 7 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 needed to judge whether the hash values of any group of sub-partitions in the static partition A and the static partition B are different, but also needed to judge whether the current system is in the upgrading 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 upgrading 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.
[0165] It can be understood that compared with the method 500 and the method 600, the method 700 further improves the reliability of the solution.
[0166] Figure 7 FIG. 9 shows an exemplary block diagram of the method 900 provided by the embodiments of the present application. 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, therefore, the descriptions in the method 400 are also applicable to the method 900, and the subsequent descriptions not described in detail can be referred to the descriptions in the method 400.
[0167] S910, in response to triggering the electronic device to execute the operation of restoring the factory setting, reading first system data from the user partition and writing the first system data into the first sub-partition, and then executing the operation of restoring the factory setting.
[0168] 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 FIG. 10. Figure 2
[0169] The memory includes a user partition and a system partition, wherein the system partition includes a first sub-partition, and the first sub-partition is an idle partition in the system partition in the process of executing the operation of restoring the factory setting, that is, in the process of executing the operation of restoring the factory setting of the electronic device, the first sub-partition is not running, that is, neither data needs to be written into the first sub-partition nor data needs to be read from the first sub-partition. Therefore, even if the first sub-partition is used for other purposes in the process of executing the operation of restoring the factory setting, it will not affect the process of restoring the factory setting of the electronic device.
[0170] In view of this, the first sub-partition is taken as a backup partition in the present application, and after detecting a trigger for the electronic device to perform the operation of restoring factory settings (such as the scenario shown in (c) in Figure 1 the first system data in the user partition is written into the first sub-partition. For example, the electronic device reads and copies the first system data from the user partition, and then writes the first system data into the first sub-partition in blocks.
[0171] 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. The first sub-partition is a backup partition for temporarily storing the first system data during the process of restoring factory settings. Therefore, the first system data can correspond to the system data C in the method 400, and the first sub-partition can correspond to the extended memory swap area and / or the modem_b in the method 400.
[0172] It can be understood that the present application does not limit the number of sub-partitions included in the first sub-partition, that is, the first sub-partition can refer to one sub-partition or multiple sub-partitions. As an example, the first sub-partition includes one or more of the following sub-partitions: multiple sub-partitions in the second static partition, the extended memory swap area in the system partition.
[0173] 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.
[0174] The first sub-partition can include one or more sub-partitions in the second static partition, such as the modem sub-partition, the boot sub-partition, the init_boot sub-partition, etc.
[0175] Optionally, in the case where the first sub-partition includes at least one sub-partition in the second static partition, that is, the electronic device uses at least one sub-partition in the second static partition as a backup partition, 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 factory settings restoration 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 as a backup partition any more, at which time the factory settings restoration 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 trigger to perform a factory reset operation, the electronic device checks whether the data in the corresponding sub-partitions of the first and second static partitions are 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 read the first system data from the user partition and write it to the first sub-partition. 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 current system is 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 if a preset storage path (such as " / data / gsi / ota") is empty. This preset storage path is used to store cached data generated during the system upgrade process. If the path is not empty, it indicates that the electronic device is in the process of system upgrade, and the factory reset process can be temporarily suspended. Only when the preset storage path is empty does the electronic device read the first system data from the user partition and write the first system data to the first sub-partition. The specific implementation process of this scheme 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.
[0176] 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 as a backup partition, the electronic device disables the first function before writing the first system data to the first subpartition.
[0177] 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. Further optionally, the electronic device can determine the size of the first system data before performing the data backup. In a case where the size of the first system data is less than or equal to a preset threshold (e.g., 3G), the electronic device reads the first system data from the user partition and writes the first system data into the first sub-partition. For details, reference can be made to the description of examples A to C in the method 400 above.
[0178] Optionally, in a possible implementation, after reading the first system data from the user partition, the electronic device can record the data length of the first system data, so as to be used for subsequent accurate recovery of the first system data.
[0179] Optionally, in a possible implementation, when the first sub-partition includes multiple sub-partitions, the electronic device can use the multiple sub-partitions to respectively backup part of the first system data, and record the order in which the data of each sub-partition is read, so as to be used for subsequent correct recovery of the first system data. For example, the first sub-partition includes a second sub-partition and a third sub-partition, and the first system data includes second system data and third system data. In the process of performing the data backup, the electronic device reads the second system data and the third system data from the user partition in sequence, and then writes the second system data and the third system data into the second sub-partition and the third sub-partition, respectively. In this case, the electronic device stores order information, which is used to indicate the order in which the electronic device reads the second system data and the third system data from the user partition.
[0180] Optionally, in a possible implementation, before performing the factory reset, the electronic device can also calculate a hash value based on the first system data, and store the hash value in a fourth sub-partition in the system partition. The hash value is used for subsequent verification of the integrity of the first system data. The fourth sub-partition is an idle partition in the system partition in the process of performing the factory reset. In a possible implementation, the fourth sub-partition does not belong to the first sub-partition, that is, the fourth sub-partition is specially used for storing the hash value, and is not used for data backup, so that the hash value and the first system data can be more conveniently read subsequently.
[0181] S920, after completing the factory reset, reading the first system data from the first sub-partition and writing the first system data into the user partition.
[0182] For example, after completing the factory reset, the electronic device recovers the first system data from the first sub-partition to the user partition, 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.
[0183] Optionally, in a possible implementation, if the electronic device stores the data length of the first system data in step S910, the electronic device can read the first system data from the first sub-partition based on the data length, thereby improving the efficiency and success rate of data reading.
[0184] Optionally, in a possible implementation, if the electronic device stores the sequence information in step S910, the electronic device can sequentially re-write the third system data and the second system data into the user partition based on the sequence information, so as to correctly recover the first system data.
[0185] Optionally, in a possible implementation, if the electronic device stores the hash value in the fourth sub-partition in step S910, the electronic device can check the integrity of the first system data by using the hash value after recovering the first system data into the user partition. If the check fails, the data in the user partition is cleared, that is, in this case, the electronic device gives up the backed-up data, at this time, the first system data can be re-acquired after the recovery of the factory setting is completed, and the specific process can refer to the example in Figure 3 Optionally, after the electronic device checks the first system data by using the hash value, the hash value can be read from the fourth sub-partition according to the data length of the hash value, wherein the length of the hash value is determined by the hash algorithm when the hash value is calculated.
[0186] Optionally, in a possible implementation, in the case where the first sub-partition includes a sub-partition (such as a second sub-partition) in the second static partition, after the first system data is re-written into the user partition, the electronic device can recover 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, thereby improving the stability of the system. For example, the electronic device copies the data in a third sub-partition to the second sub-partition, wherein the third sub-partition belongs to the first static partition, and the third sub-partition corresponds to the second sub-partition.
[0187] In summary, in the above method 900, the system partition of the electronic device selects the first sub-partition in the idle state in the recovery of the factory setting process as the backup partition, so that even if the first system data is temporarily stored in the first sub-partition, the recovery of the factory setting process will not be affected. After the first system data is backed up to the first sub-partition, the recovery of the factory setting process can be normally performed, and after the recovery of the factory setting process is completed, that is, after the user partition is formatted, the first system data is directly recovered from the first sub-partition to the user partition, which can improve the efficiency of data recovery, and at the same time, some problems caused by the re-generation of the first system data can be avoided, such as serious device heating, network lag, system lag, etc.
[0188] Figure 8 is a hardware structure schematic diagram of the electronic device 1000 provided by the embodiment of the present application. As shown in the figure, 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 also include a sensor 1050 and a display screen 1060. Figure 8
[0189] It can be understood that the structure shown in the 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 the diagram, or combine certain components, or split certain components, or different component arrangements. The components shown in the diagram can be implemented in hardware, software, or a combination of software and hardware.
[0190] 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.
[0191] The memory 1020 can be used to store computer-executable program code including instructions. The processor 1010 executes various functional applications and data processing of the electronic device 1000 by running the instructions stored in the memory 1020.
[0192] Exemplarily, in the technical solutions provided by 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 execute the factory resetting method provided by the embodiments of the present application.
[0193] The present application does not limit the memory structure of the memory 1020. In a possible implementation, the memory can adopt, for example, Figure 2 The illustrated structure. In one 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 user personal installed applications, user personal saved pictures, documents, and videos, and other personal data. In the embodiment 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.
[0194] In the process of performing the factory reset, the electronic device formats the user partition 1020b, that is, clears the user data and system data stored in the user partition 1020b. In the scheme provided in the embodiment of the present application, the system data in the user partition 1020b can be backed up through the sub-partition in the system partition 1020a, and the backed up data can be restored to the user partition 1020b after the factory reset is completed. The specific implementation process can refer to the description in the method 400 or the method 900, which will not be described here.
[0195] The wireless communication function of the electronic device 1000 can be realized 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.
[0196] 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 technology (IR), and other wireless communication applied to the electronic device 1000.
[0197] As an example, the electronic device 1000 can connect to a 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.
[0198] 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.
[0199] 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, the electronic device 1000 can also display prompt information through the display screen if it is detected that the data in the static partition A and the static partition B is inconsistent, and / or it is detected that the electronic device 1000 is currently performing a system upgrade, 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
[0200] 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 together 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.
[0201] As an example, the electronic device 1000 detects, by the touch sensor 1050a, an instruction input by a user indicating to restore factory settings, and then executes the scheme provided in the embodiments of the present application. Referring to Figure 1 In (c) of FIG. 1, after the electronic device 1000 detects, by the touch sensor 1050a, a click operation acting on the control 104, the electronic device 1000 executes the scheme provided in the embodiments of the present application.
[0202] The methods in the embodiments of the present application can be implemented in the electronic device 1000 with the hardware structure described above.
[0203] As to the hardware structure of the electronic device, it is understood that, Figure 8 The components included in the hardware structure shown 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.
[0204] The embodiments of the present application also 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.
[0205] The embodiments of the present application provide a computer program product, which, when running on an apparatus, causes the apparatus to implement the steps in each of the above method embodiments.
[0206] The embodiments of the present application provide a chip, which 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 repeated here.
[0207] 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.
[0208] 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.
[0209] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail or recorded in a certain embodiment can be referred to the relevant description of other embodiments.
[0210] 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.
[0211] 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 device embodiments described above are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, 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.
[0212] It should be understood that the "embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment 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 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.
[0213] The above described embodiments are only used to illustrate the technical solutions of the present application, but not to limit it; 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 equivalents; 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.
[0214] 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.
[0215] The terms "comprise" and "have" 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.
[0216] In the embodiments of the present application, the words "exemplarily" or "for example" 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" are intended to present the relevant concept in a specific manner.
[0217] 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 of restoring factory settings, characterized by, The method is applied to an electronic device, the electronic device includes a memory, the memory includes a user partition and a system partition, the system partition includes a first sub-partition, and the method includes: In response to triggering the electronic device to perform a factory reset operation, reading first system data from the user partition and writing the first system data to the first sub-partition, and then performing a factory reset, the first sub-partition being a free partition in the system partition during the process of performing a factory reset; After completing the factory reset, reading the first system data from the first sub-partition and re-writing the first system data to the user partition.
2. The method of claim 1, wherein, The system partition includes a first static partition and a second static partition, and an operating system of the electronic device is currently running in the first static partition, and 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.
3. The method of claim 2, wherein, In the case where the first sub-partition includes the extended memory swap area, before the writing of the first system data to the first sub-partition, the method further includes: Turning off a first function for setting the extended memory swap area as a running memory of the electronic device.
4. The method according to claim 2 or 3, characterized in that, Before the reading of the first system data from the user partition and the writing of the first system data to the first sub-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.
5. The method according to claim 2 or 3, characterized in that, In the case where the first sub-partition includes a second sub-partition in the second static partition, after the re-writing of the first system data to the user partition, the method further includes: Copying 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.
6. The method according to any one of claims 1 to 5, characterized in that, The reading of the first system data from the user partition and the writing of the first system data to the first sub-partition include: In the case where the size of the first system data is less than or equal to a preset threshold, reading the first system data from the user partition and writing the first system data to the first sub-partition.
7. The method of any one of claims 1 to 6, wherein, After the reading of the first system data from the user partition, the method further includes: Recording a data length of the first system data; The reading of the first system data from the first sub-partition includes: Reading the first system data from the first sub-partition according to the data length.
8. The method of any one of claims 1 to 7, wherein: The first sub-partition includes a second sub-partition and a third sub-partition, the first system data includes second system data and third system data, and the reading of the first system data from the user partition and the writing of the first system data to the first sub-partition include: read the second system data and the third system data from the user partition in sequence, and then write the second system data and the third system data into the second sub-partition and the third sub-partition respectively; The method further includes: storing sequence information, the sequence information being used to indicate an order in which the electronic device reads the second system data and the third system data from the user partition; The re-writing of the first system data into the user partition includes: re-writing the third system data and the second system data into the user partition in sequence based on the sequence information.
9. The method of any one of claims 1-8, wherein, Before the performing of the factory reset, the method further includes: calculating a hash value from the first system data, and storing the hash value in a fourth sub-partition in the system partition, the fourth sub-partition being an idle partition in the system partition during the performing of the factory reset; After the re-writing of the first system data into the user partition, the method further includes: verifying integrity of the first system data in the user partition using the hash value; in the case of a verification failure, clearing data in the user partition.
10. The method of claim 9, wherein, Before the verifying of the integrity of the first system data in the user partition using the hash value, the method further includes: reading the hash value from the fourth sub-partition according to a data length of the hash value.
11. The method according to claim 9 or 10, characterized in that, The fourth sub-partition is not the first sub-partition.
12. An electronic device, comprising: The electronic device includes one or more processors, and a memory; The memory is coupled to the one or more processors, and the memory is configured to store computer program codes, the computer program codes including computer instructions, the one or more processors invoking the computer instructions to cause the electronic device to perform the method of any one of claims 1-11.
13. A chip system, characterized by The chip system is applied to an electronic device, and the chip system includes one or more processors, the one or more processors being configured to invoke computer instructions to cause the electronic device to perform the method of any one of claims 1-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 of any one of claims 1-11.