A method and device for restoring factory settings
By checking the time to detect whether the command is received again within the target time period after receiving the target instruction, and restoring the factory settings when the preset number is reached, the problem of false triggering in the prior art is solved, and more accurate factory settings operations are achieved, and user losses are reduced.
Patent Information
- Application Number
- CN202210319168.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-29
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2042-03-29
AI Technical Summary
The existing factory reset method of electronic equipment is easily triggered by mistake, resulting in user losses.
By timing the target instruction after receiving the target instruction, checking whether the command is received again within the target duration, and factory settings are restored when the preset number is reached, the target duration and flag value are used to determine the user's real needs.
It effectively avoids factory resetting of electronic devices caused by accidental touch operations and reduces user losses.
Smart Images

Figure CN114816844B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for restoring factory settings. Background Art
[0002] Restoring factory settings means restoring an electronic device to its default state when it left the factory.
[0003] Currently, there are mainly two methods for an electronic device to restore factory settings: one is to restore factory settings by triggering the restore factory settings button of the electronic device. Once the restore factory settings button is triggered, the electronic device immediately performs the operation of restoring factory settings; the other is to control the electronic device to restore factory settings through network communication. Once a restore factory settings instruction is sent to the electronic device through network communication, the electronic device immediately performs the operation of restoring factory settings. Although the above two methods for restoring factory settings can quickly restore the electronic device to its factory settings, once the button is accidentally triggered or the restore factory settings instruction is accidentally sent, even if the user does not really need the electronic device to perform the operation of restoring factory settings, the electronic device will immediately perform the operation of restoring factory settings, bringing inevitable losses to the user. Summary of the Invention
[0004] In view of this, the present invention proposes a method and device for restoring factory settings, and the main purpose is to avoid the electronic device performing the operation of restoring factory settings due to accidental touch operations.
[0005] In order to achieve the above object, the present invention mainly provides the following technical solutions:
[0006] In a first aspect, the present invention provides a method for restoring factory settings, the method comprising:
[0007] Each time a target instruction is received, starting from the time point when the target instruction is received, it is detected whether the target instruction is received again within a target duration, wherein the target instruction is an instruction related to restoring factory settings of a target device;
[0008] When it is detected that the target instruction is received again within the target duration, the value of the flag bit for restoring factory settings is incremented by one;
[0009] When it is determined that the current value of the flag bit reaches a first preset value, an operation of restoring factory settings is performed on the target device.
[0010] In a second aspect, the present invention provides a device for restoring factory settings, the device comprising:
[0011] The first detection unit is configured to start timing from the time point when a target instruction is received each time the target instruction is received, and detect whether the target instruction is received again within a target duration, where the target instruction is an instruction related to the factory reset of a target device;
[0012] The second detection unit is configured to increment the value of the flag bit for factory reset when it is detected that the target instruction is received again within the target duration;
[0013] The processing unit is configured to perform a factory reset operation on the target device when it is determined that the current value of the flag bit reaches a first preset value.
[0014] In a third aspect, the present invention provides a computer-readable storage medium, where the storage medium includes a stored program, and when the program runs, it controls the device where the storage medium is located to execute the method for factory reset provided in the first aspect.
[0015] In a fourth aspect, the present invention provides an electronic device, where the electronic device includes:
[0016] A memory for storing a program;
[0017] A processor coupled to the memory for running the program to execute the method for factory reset provided in the first aspect.
[0018] By means of the above technical solutions, for the method and device for factory reset provided by the present invention, each time a target instruction is received, timing starts from the time point when the target instruction is received, and it is detected whether the target instruction is received again within a target duration. Once it is detected that the target instruction is received again within the target duration, the value of the flag bit for factory reset is incremented. When it is determined that the current value of the flag bit reaches a first preset value, a factory reset operation is performed on the target device. It can be seen that in the solution provided by the present invention, two factors, namely the target duration and the value of the flag bit, are used to determine whether the electronic device really needs to perform a factory reset. That is, each time a target instruction is received, a target duration is given, and only when the target instruction is received again within the target duration, the value of the flag bit will be incremented. And only when the value of the flag bit reaches the preset value will the target device be triggered to perform a factory reset. Since the solution provided by the present invention uses two factors, namely the target duration and the value of the flag bit, to determine whether the electronic device really needs to perform a factory reset, it can effectively avoid the factory reset operation of the electronic device caused by accidental touch operations, thereby avoiding the losses brought to users by the accidental factory reset of the electronic device.
[0019] The above description is only an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention, it can be implemented according to the content of the specification. In order to make the above and other objects, features, and advantages of the present invention more obvious and understandable, the specific embodiments of the present invention are specifically exemplified below. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0021] Figure 1 The flowchart of a method for restoring factory settings provided by an embodiment of the present invention is shown;
[0022] Figure 2 The flowchart of a method for restoring factory settings provided by another embodiment of the present invention is shown;
[0023] Figure 3 The schematic structural diagram of a device for restoring factory settings provided by an embodiment of the present invention is shown;
[0024] Figure 4 The schematic structural diagram of a device for restoring factory settings provided by another embodiment of the present invention is shown. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0025] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be fully conveyed to those skilled in the art.
[0026] With the development of technology, electronic devices such as embedded devices have become essential tools in people's daily life and work. There are usually the following two problems in the use of existing electronic devices: First, the electronic device needs to change the application environment; second, various applications are installed on the electronic device, and the operation of these applications will generate application data in the electronic device. The accumulation of these application data will cause phenomena such as unsmooth operation and card machine of the electronic device. Restoring the factory settings of the electronic device can effectively solve the above two problems.
[0027] At present, there are mainly the following two methods for an electronic device to restore factory settings: One is to restore factory settings by triggering the restore factory settings button of the electronic device. Once the restore factory settings button is triggered, the electronic device immediately executes the restore factory settings; the other is to control the electronic device to restore factory settings through network communication. Once a restore factory settings instruction is sent to the electronic device through network communication, the electronic device immediately executes the restore factory settings. Although the above two methods for restoring factory settings can quickly restore the electronic device to factory settings, once the button is accidentally triggered or the restore factory device instruction is accidentally sent, even if the user does not really need the electronic device to perform the restore factory settings operation, the electronic device will immediately execute the restore factory device, bringing inevitable losses to the user.
[0028] It can be seen that the existing methods for restoring factory settings are easily accidentally triggered and may cause losses to users. Therefore, in order to avoid the electronic device from executing the restore factory settings operation due to accidental touch operations, the embodiments of the present invention provide a method and device for restoring factory settings. The method and device for restoring factory settings provided by the embodiments of the present invention can be applied to electronic devices such as embedded devices and non-embedded devices to prevent these electronic devices from being accidentally touched and triggering the restore factory settings operation. The method and device for restoring factory settings provided by the embodiments of the present invention will be specifically described below.
[0029] As Figure 1 shown, the embodiments of the present invention provide a method for restoring factory settings, which mainly includes:
[0030] 101. Each time a target instruction is received, start timing from the time point when the target instruction is received, and detect whether the target instruction is received again within the target duration, where the target instruction is an instruction related to the restore factory settings of the target device.
[0031] The method for restoring factory settings provided in this embodiment can be applied to any electronic device that has a need to restore factory settings. The specific type of the electronic device mentioned here is not specifically limited in this embodiment. Optionally, the electronic device can be an embedded device or a non-embedded device.
[0032] In practical applications, it is possible to determine whether to perform a factory reset operation on the target device through a target instruction, where the target instruction is an instruction related to the factory reset of the target device. There are two types of target instructions as follows: First, the target instruction is a system startup instruction for the target device, which is generated when the system startup button of the electronic device is triggered or a system startup instruction is sent to the electronic device through network communication; Second, the target instruction is a factory reset instruction for the target device, which is generated when the factory reset button of the electronic device is triggered or a factory reset instruction is sent to the electronic device through network communication.
[0033] To avoid accidental touch from triggering the electronic device to perform a factory reset operation, each time a target instruction is received, the following operations will be performed: Starting from the time point when the target instruction is received, it is detected whether the target instruction is received again within the target duration. The following describes the specific method of starting from the time point when the target instruction is received and detecting whether the target instruction is received again within the target duration. This method includes at least the following several types:
[0034] First, the specific process of starting from the time point when the target instruction is received and detecting whether the target instruction is received again within the target duration includes the following steps 101A1 to 101A5:
[0035] 101A1. Starting from the time point when the target instruction is received, it is detected whether the target instruction is received again at each preset duration interval.
[0036] To determine in a timely manner whether the target instruction is received again, starting from the time point when the target instruction is received, it is detected whether the target instruction is received again at each preset duration interval. The process of starting from the time point when the target instruction is received and detecting whether the target instruction is received again at each preset duration interval can be implemented through the following two types of threads:
[0037] First, it can be completed by a detection thread constructed by a thread function. The preset duration is the time interval between two adjacent detections. To reduce the computing power of the detection thread, within the preset duration between two adjacent detections, the detection thread can sleep. The sleep can be performed by calling a sleep function. Exemplarily, the time point when the target instruction is received is 8:00, and the preset duration is 1 second. Starting from the time point 8:00 when the target instruction is received, it is detected whether the target instruction is received again at each preset duration of "1 second". That is to say, after each detection of whether the target instruction is received again, the detection thread sleeps for 1 second before performing the next detection.
[0038] Second, call the target timer thread, set the time point when the target timer thread receives the target instruction and the preset duration, so that the target timer thread starts from this time point and detects whether the target instruction is received again every preset duration. To reduce the computing power of the target timer thread, the target timer thread can sleep during the preset duration between two adjacent detections. The sleep can be performed by calling the sleep function.
[0039] 101A2. If it is detected that the target instruction is received again in the current detection, it is determined that the target instruction is received again within the target duration, and step 102 can be executed.
[0040] If it is detected that the target instruction is received again in a current detection, it indicates that the user has probably triggered the factory reset button again, or sent a factory reset instruction to the electronic device through network communication. Then it is determined that the target instruction is received again within the target duration, and step 102 can be continued to be executed.
[0041] 101A3. If it is detected that the target instruction is not received again in the current detection, subtract the preset duration corresponding to the current detection from the target duration.
[0042] If it is detected that the target instruction is not received again in a current detection, it indicates that the user has not triggered the factory reset button again, or the user has not sent a factory reset instruction to the electronic device through network communication. At this time, it is necessary to subtract the preset duration corresponding to the current detection from the target duration to determine whether it is necessary to continue to detect whether the target instruction is received again based on the value after subtracting the preset duration corresponding to the current detection from the target duration.
[0043] The main purpose of subtracting the preset duration corresponding to the current detection from the target duration is to update the time limit for detecting whether the target instruction is received again. This time limit is a key factor for excluding accidental factory reset operations.
[0044] 101A4. Determine whether the value after subtracting the preset duration corresponding to the current detection from the target duration is the target value. If so, execute step 101A5; otherwise, continue to execute step 101A1.
[0045] The target value is the criterion for determining whether to continue to detect whether the target instruction is received again. Therefore, it is necessary to determine whether the value after subtracting the preset duration corresponding to the current detection from the target duration is the target value to determine whether it is necessary to continue to detect whether the target instruction is received again according to the judgment result. The target value can be determined based on business requirements, and this embodiment does not make specific limitations. Exemplarily, the target value is 0.
[0046] After determining that the value obtained by subtracting the preset duration corresponding to the current detection from the target duration is the target value, it indicates that within a certain period of time, the user has not issued the target instruction again. Then, perform step 101A5 to determine that the target instruction has not been received again within the target duration. Determining that the target instruction has not been received again within the target duration to some extent indicates that the currently received target instruction is likely to be accidentally triggered by the user, or after the user issues the current target instruction, the user's requirement to restore the device to factory settings has changed, and the user may no longer need to restore the device to factory settings.
[0047] When the value obtained by subtracting the preset duration corresponding to the current detection from the target duration is not the target value, it indicates that the time limit has not been reached, and it cannot be determined whether the currently received target instruction is generated by an accidental touch operation. Therefore, step 101A1 can be continued to continue to detect whether the target instruction is received again at intervals of the preset duration.
[0048] 101A5. Determine that the target instruction has not been received again within the target duration.
[0049] Second, starting from the time point when the target instruction is received, the specific process of detecting whether the target instruction is received again within the target duration includes the following steps 101B1 to 101B5:
[0050] 101B1. Set a timer based on the time point when the target instruction is received and the target duration.
[0051] The timer has the same function as an alarm clock and is set according to the time point when the target instruction is received and the target duration. Exemplarily, if the time point when the target instruction is received is 8:00 and the target duration is 1 minute, the timer is a timer that is set to 8:01.
[0052] 101B2. Continuously determine whether the timer has expired.
[0053] The process of continuously determining whether the timer has expired can be: starting from the time point when the target instruction is received, detect whether the timer has expired at intervals of the preset duration. This process can be completed by a detection thread constructed by a thread function. The preset duration is the time interval between two adjacent detections. In order to reduce the computing power of the detection thread, within the preset duration between two adjacent detections, the detection thread can sleep.
[0054] 101B3. If it is determined that the timer has expired, detect whether there is a target instruction received again stored in the preset storage area.
[0055] When the timer expires, it indicates that the time limit for detecting whether the target instruction is received again has been reached. Therefore, it is necessary to detect whether there is a target instruction received again stored in the preset storage area.
[0056] In order to reduce the number of times of detecting whether the target instruction is received again and lower the computing power input for detecting whether the target instruction is received again, if the target instruction is received again within the target duration after receiving the target instruction, the received target instruction is directly stored in the preset storage area. When the timer expires, directly detect whether there is a received target instruction stored in the preset storage area.
[0057] 101B4. If it is detected that there is a received target instruction stored, it is determined that the target instruction is received again within the target duration, and step 102 is executed.
[0058] If it is detected that there is a received target instruction stored, it indicates that within a certain period of time, the user has probably triggered the factory reset button or sent a factory reset instruction to the electronic device through network communication. It is highly probable that the user has a need to perform a factory reset on the target device. Then, it is determined that the target instruction is received again within the target duration, and step 102 can be continued to be executed.
[0059] 101B5. If it is detected that there is no received target instruction stored, it is determined that the target instruction is not received again within the target duration.
[0060] This indicates that within a certain period of time, the user has not sent the target instruction again. Then, it is determined that the target instruction is not received again within the target duration. Determining that the target instruction is not received again within the target duration to a certain extent indicates that the currently received target instruction is likely to be sent by the user by mistake, or after sending the current target instruction, the user's need to reset the device to the factory settings has changed, and the user may no longer need to perform a factory reset.
[0061] Thirdly, starting from the time point when the target instruction is received, the specific process of detecting whether the target instruction is received again within the target duration includes the following steps 101C1 to 101C4:
[0062] 101C1. Call the timer thread. The timer thread is used to start timing from the time point when the target instruction is received and set the global variable value to the preset value when the timed duration reaches the target duration. The preset value is a flag for updating the flag bit value.
[0063] The timer thread is used for time counting, and its counting is based on the time point when the target instruction is received and the preset duration. The global variable value is used to reflect the time counting situation of the timer thread. When the duration counted by the timer reaches the target duration, the global variable value will be set to the preset value to inform the timer thread that the counted duration has reached the target duration. The preset value described here can be set according to specific business requirements and is not specifically limited in this embodiment. Exemplarily, the preset value of the global variable value is DS. When the preset value of the global variable value is DS, it indicates that the duration counted by the timer thread has reached the target duration.
[0064] The timer thread starts timing from the time point when the target instruction is received, and when the counted duration reaches the target duration, it sets the global variable value to the preset value to inform whether the target instruction can be detected to be received again.
[0065] 101C2. When it is detected that the global variable value is the preset value, it is detected whether there is a target instruction received again stored in the preset storage area.
[0066] In order to reduce the number of times of detecting whether the target instruction is received again and reduce the computing power input for detecting whether the target instruction is received again, if the target instruction is received again within the target duration after the target instruction is received, the target instruction received again is directly stored in the preset storage area. When the global variable value is the preset value, it is directly detected whether there is a target instruction received again stored in the preset storage area.
[0067] 101C3. If it is detected that there is a target instruction received again stored, it is determined that the target instruction is received again within the target duration, and step 102 is executed.
[0068] If it is detected that there is a target instruction received again stored, it indicates that within a certain period of time, the user has probably triggered the factory reset button, or sent a factory reset instruction to the electronic device through network communication. The user probably has a need to perform a factory reset on the target device. Then it is determined that the target instruction is received again within the target duration, and step 102 can be continued to be executed.
[0069] 101C4. If it is detected that there is a target instruction received again stored, it is determined that the target instruction is not received again within the target duration.
[0070] It indicates that within a certain period of time, the user has not sent the target instruction again. Then it is determined that the target instruction is not received again within the target duration. Determining that the target instruction is not received again within the target duration to a certain extent indicates that the currently received target instruction is likely to be sent by the user by mistake, or after the user sends the current target instruction, the user's demand for factory resetting the device has changed, and the user may no longer need to perform a factory reset.
[0071] It should be noted that the detection threads, timers, etc. involved in the above three methods are created for the currently received target instruction each time a target instruction is received. After creation, they are destroyed after it is determined that no target instruction is received again within the target duration or after it is determined that a target instruction is received again within the target duration.
[0072] 102. When it is detected that a target instruction is received again within the target duration, increment the flag value for restoring the factory settings by one.
[0073] The flag value is an important basis for determining whether the target device performs a factory reset operation, and its specific meaning is related to the type of the target instruction. When the target instruction is a system startup instruction for the target device, the flag value represents the number of times the system of the target device has been started. When the target instruction is a factory reset instruction for the target device, the flag value represents the number of received factory reset instructions.
[0074] When it is detected that a target instruction is received again within the target duration, it indicates that the issuance of the target instruction is probably not caused by an accidental touch operation. Therefore, increment the flag value for restoring the factory settings by one. The purpose of incrementing the flag value by one is to use the flag value to further reflect the user's demand for restoring the factory settings of the target device.
[0075] The value of the flag before the increment operation is related to the number of times and the acquisition time of the target instruction. The examples are as follows:
[0076] Exemplarily, when the target instruction is received for the first time, the flag value is a preset value, such as 0. When the target instruction is received for the first time, start timing from the time point when the target instruction is received. If it is detected that a target instruction is received again within the target duration, then increment the flag value of 0 by one, and the flag value becomes 1. Relative to the target instruction received for the first time, the target instruction received again is the target instruction received for the second time. When the target instruction is received for the second time, start timing from the time point when the target instruction is received for the second time. If it is detected that a target instruction is received again within the target duration, then increment the flag value of 1 by one, and the flag value becomes 2.
[0077] 103. When it is determined that the current flag value reaches the first preset value, perform a factory reset operation on the target device.
[0078] The current flag value can reflect the degree of the user's need to perform a factory reset on the target device. The first preset value represents the boundary value of the degree of the user's need to perform a factory reset on the target device. Therefore, it is necessary to compare the current flag value with the first preset value to determine whether the user truly needs to perform a factory reset on the target device based on the comparison result. In order to more reasonably and user-friendly assist the user in performing a factory reset operation on the electronic device at the necessary moment, the setting authority of the first preset value can be handed over to the user.
[0079] When it is determined that the current flag value reaches the first preset value, it indicates that the user has a relatively high degree of need to perform a factory reset on the target device, and the user truly needs to perform a factory reset on the target device, then perform a factory reset operation on the target device.
[0080] The specific methods for performing a factory reset operation on the target device include the following several types:
[0081] First, when it is determined that the current flag value reaches the first preset value, determine whether the target application in the target device is running. Among them, the target application is specified by the user, and after it is factory reset, it may cause losses to the user. When it is determined that the target application is running, issue a prompt for factory reset to inform the user that the target device is about to perform a factory reset. When receiving the user's confirmation instruction, perform a factory reset on the target device.
[0082] Second, when it is determined that the current flag value reaches the first preset value, determine whether there is data in the preset storage area of the target device. When it is determined that there is data, transfer the existing data to the preset storage location. After the transfer of the existing data to the preset storage location is completed, perform a factory reset on the target device. Among them, the data in the preset storage area may cause losses to the user after it is factory reset.
[0083] Third, when it is determined that the current flag value reaches the first preset value, issue a prompt for factory reset to inform the user that the target device is about to perform a factory reset. When receiving the user's confirmation instruction, perform a factory reset on the target device.
[0084] Fourth, when it is determined that the current flag value reaches the first preset value, directly perform a factory reset on the target device.
[0085] When it is determined that the current flag value has not reached the first preset value, it indicates that the user's demand for restoring the target device to factory settings is relatively small. The target instruction may be triggered by mistake, and the user does not really need to restore the target device to factory settings. Then, the flag value is set to the second preset value. The second preset value reflects that the user's demand for restoring the target device to factory settings is relatively small, or the user has no demand for restoring the target device to factory settings.
[0086] In the method for restoring to factory settings provided by the embodiments of the present invention, each time a target instruction is received, timing starts from the time point when the target instruction is received, and it is detected whether the target instruction is received again within the target duration. Once it is detected that the target instruction is received again within the target duration, the flag value for restoring to factory settings is incremented by one. When it is determined that the current flag value reaches the first preset value, an operation of restoring the target device to factory settings is performed. It can be seen that in the solution provided by the present invention, two factors, namely the target duration and the flag value, are used to determine whether the electronic device really needs to perform a factory reset. That is, each time a target instruction is received, a target duration is given, and only when the target instruction is received again within the target duration, the flag value will be increased. And only when the flag value reaches the preset value will the target device be triggered to perform a factory reset. Since the solution provided by the embodiments of the present invention uses two factors, namely the target duration and the flag value, to determine whether the electronic device really needs to perform a factory reset, it can effectively avoid the operation of the electronic device performing a factory reset caused by accidental touch, thereby avoiding the loss to the user caused by the electronic device being accidentally restored to factory settings.
[0087] Further, according to Figure 1 the method shown, another embodiment of the present invention also provides a method for restoring to factory settings, as Figure 2 shown, the method mainly includes:
[0088] 201. Add a flag bit to the target storage area of the target device.
[0089] The flag bit is used to identify the flag value, and it is the basis for querying and obtaining the flag value. The target storage area is used to store the flag bit and the flag value corresponding to the flag bit. The target storage area can be any storage area in the target device. Exemplarily, the target storage area is some software and hardware modules in the target device that have the function of storing data, such as a file system or a FLASH chip driver, etc.
[0090] The specific process of adding a flag bit to the target storage area of the target device is as follows: When the target device is started for the first time, initialize the target module in the target device that has the function of storing data, where the target module can be specified by the user. Then add a flag bit to the target module. The specific type of the flag bit is not limited in this embodiment. For example, the flag bit is set to BZW and added within the target storage area.
[0091] 202. The flag bit value corresponding to the initial flag bit for factory reset.
[0092] To facilitate the use of the flag bit, after adding the flag bit to the target storage area of the target device, it is necessary to initialize the flag bit value corresponding to the initial flag bit for factory reset, so as to judge the factory reset based on the initial flag bit value.
[0093] The initial flag bit value can be determined based on specific business requirements, and this embodiment does not make specific limitations. Exemplarily, the flag bit value corresponding to the initial flag bit for factory reset is 0. When initializing the flag bit value corresponding to the initial flag bit for factory reset, it is necessary to establish the correspondence between the flag bit value and the flag bit, so as to facilitate querying the flag bit data according to the flag bit.
[0094] 203. Monitor the target instruction.
[0095] The target instruction is an instruction related to the factory reset of the target device. There are the following two types of target instructions:
[0096] First, the target instruction is a system start instruction for the target device. This system start instruction is an instruction generated when the system start button of the electronic device is triggered, or a system start instruction sent to the electronic device through network communication. When the target instruction is a system start instruction, the electronic device system can operate normally under the system start instruction, and it will not affect the normal operation of the electronic device and will not cause abnormal situations such as the electronic device system not being able to start.
[0097] Second, the target instruction is a factory reset instruction for the target device. This factory reset instruction is an instruction generated when the factory reset button of the electronic device is triggered, or a factory reset instruction sent to the electronic device through network communication.
[0098] 204. When receiving the target instruction, start timing from the time point when the target instruction is currently received, and detect whether the target instruction is received again within the target duration. When it is detected that the target instruction is received again within the target duration, execute step 205; when it is detected that the target instruction is not received again within the target duration, execute step 206.
[0099] 205. Increment the value of the flag bit for restoring the factory settings by one, and perform step 207.
[0100] When the target instruction is received again within the detected target duration, it indicates that the issuance of the target instruction is probably not caused by accidental touch operation. Therefore, increment the value of the flag bit for restoring the factory settings by one. The purpose of incrementing the value of the flag bit is to use the value of the flag bit to further reflect the degree of the user's demand for restoring the factory settings of the target device.
[0101] 206. Set the value of the flag bit to the second preset value, and perform step 203.
[0102] When the target instruction is not received again within the detected target duration, it indicates that the currently received target instruction is likely to be accidentally issued by the user, or the user's demand for restoring the factory settings of the device has changed after issuing the current target instruction, and the user may no longer need to restore the factory settings. Then set the value of the flag bit to the second preset value, that is, initialize the value of the flag bit again and recalculate the cumulative flag value.
[0103] The second preset value can be determined based on business requirements, and no specific limitation is provided in this embodiment. Optionally, the second preset value can be 0.
[0104] 207. Determine whether the current value of the flag bit reaches the first preset value; if it reaches, perform step 208; otherwise, perform step 209.
[0105] 208. Perform an operation to restore the factory settings of the target device.
[0106] 209. Use the target instruction received again as the currently received target instruction, and perform step 204.
[0107] When it is determined that the current flag value does not reach the first preset value, use the target instruction received again as the currently received target instruction, and perform step 204 to start timing from the time point when the target instruction received again is received, and detect whether the target instruction is received again within the target duration.
[0108] Further, according to the above method embodiment, another embodiment of the present invention also provides a device for restoring the factory settings, as Figure 3 shown, the device includes:
[0109] A first detection unit 31, configured to start timing from the time point when each target instruction is received, and detect whether the target instruction is received again within the target duration, where the target instruction is an instruction related to restoring the factory settings of the target device;
[0110] The second detection unit 32 is configured to increment the value of the flag bit for restoring the factory settings by one when it detects that the target instruction is received again within the detected target duration;
[0111] The processing unit 33 is configured to perform a factory reset operation on the target device when it determines that the current value of the flag bit reaches a first preset value.
[0112] In the device for restoring the factory settings provided by the embodiments of the present invention, each time a target instruction is received, timing starts from the time point when the target instruction is received, and it is detected whether the target instruction is received again within the target duration. Once it is detected that the target instruction is received again within the target duration, the value of the flag bit for restoring the factory settings is incremented by one. When it is determined that the current value of the flag bit reaches the first preset value, a factory reset operation is performed on the target device. It can be seen that in the solution provided by the present invention, two factors, namely the target duration and the value of the flag bit, are used to determine whether the electronic device really needs to perform a factory reset. That is, each time a target instruction is received, a target duration is given, and only when the target instruction is received again within the target duration, the value of the flag bit will be incremented. And only when the value of the flag bit reaches the preset value will the target device be triggered to perform a factory reset. Since the solution provided by the embodiments of the present invention uses two factors, namely the target duration and the value of the flag bit, to determine whether the electronic device really needs to perform a factory reset, it can effectively avoid the factory reset operation of the electronic device caused by accidental touch operations, thereby avoiding the losses brought to users by the electronic device being accidentally restored to the factory settings.
[0113] Optionally, as Figure 4 shown, the device further includes:
[0114] The first setting unit 34 is configured to set the value of the flag bit to a second preset value when it detects that the target instruction is not received again within the target duration.
[0115] Optionally, as Figure 4 shown, the first detection unit 31 is further configured to start timing from the time point of the target instruction received again and detect whether the target instruction is received again within the target duration when it determines that the current flag value does not reach the first preset value.
[0116] Optionally, as Figure 4 shown, the first detection unit 31 includes:
[0117] The first detection module 311 is configured to detect whether the target instruction is received again every preset duration starting from the time point.
[0118] The first determination module 312 is configured to determine that the target instruction is received again within the target duration if it is detected that the target instruction is received again under the current detection.
[0119] The second detection module 313 is configured to subtract the preset duration corresponding to the current detection from the target duration if it is detected that the target instruction is not received again under the current detection; if it is determined that the value after subtracting the preset duration corresponding to the current detection from the target duration is the target value, it is determined that the target instruction is not received again within the target duration.
[0120] Optionally, as Figure 4 shown, the first detection unit 31 includes:
[0121] The setting module 314 is configured to set a timer based on the time point when the target instruction is received and the target duration.
[0122] The judgment module 315 is configured to repeatedly judge whether the timer expires.
[0123] The third detection module 316 is configured to detect whether the target instruction received again is stored in the preset storage area if it is determined that the timer expires; if it is detected that the target instruction received again is stored, it is determined that the target instruction is received again within the target duration.
[0124] Optionally, as Figure 4 shown, the first detection unit 31 includes:
[0125] The calling module 317 is configured to call a timer thread, where the timer thread is used to start timing from the time point when the target instruction is received and set the global variable value to a preset value when the timed duration reaches the target duration, where the preset value is a flag for updating the flag bit value.
[0126] The fourth detection module 318 is configured to detect whether the target instruction received again is stored in the preset storage area when it is detected that the global variable value is the preset value; if it is detected that the target instruction received again is stored, it is determined that the target instruction is received again within the target duration.
[0127] Optionally, as Figure 4 shown, the device further includes:
[0128] The second setting unit 35 is configured to add a flag bit to the target storage area of the target device; initialize the flag bit value corresponding to the factory reset.
[0129] Optionally, as Figure 4As shown, the target instruction involved in the device is a system startup instruction for a target device, and the flag bit value represents the number of times the target device has been started; or, the target instruction is a factory reset instruction for the target device, and the flag bit value represents the number of received factory reset instructions.
[0130] In the device for factory reset provided by the embodiments of the present invention, each functional module can execute the corresponding steps of the foregoing method embodiments, which will not be elaborated herein.
[0131] Furthermore, according to the above embodiments, another embodiment of the present invention further provides a computer-readable storage medium. The storage medium includes a stored program. When the program runs, it controls the device where the storage medium is located to execute the factory reset method described in the foregoing method embodiments.
[0132] Furthermore, according to the above embodiments, another embodiment of the present invention further provides an electronic device, which includes:
[0133] A memory for storing a program;
[0134] A processor coupled to the memory for running the program to execute the factory reset method described in the foregoing method embodiments.
[0135] In the above embodiments, the descriptions of the various embodiments have their own focuses. For parts not elaborated in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0136] It can be understood that the relevant features in the above methods and devices can be referred to each other. In addition, the "first", "second", etc. in the above embodiments are used to distinguish the embodiments, and do not represent the advantages and disadvantages of each embodiment.
[0137] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, which will not be elaborated herein.
[0138] The algorithms and displays provided herein are not inherently related to any specific computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. Based on the above description, the structure required to construct such a system is obvious. In addition, the present invention is not directed to any specific programming language. It should be understood that the content of the present invention described herein can be implemented using various programming languages, and the description of the specific language above is for disclosing the best mode of the present invention.
[0139] In the specification provided herein, a large number of specific details are set forth. However, it will be understood that embodiments of the present invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0140] In addition, those skilled in the art will understand that although some embodiments described herein include certain features included in other embodiments but not others, the combination of features of different embodiments is meant to be within the scope of the present invention and forms different embodiments. For example, in the following claims, any one of the claimed embodiments can be used in any combination.
[0141] Embodiments of various components of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) can be used in practice to implement some or all of the functions of some or all of the components in the method, apparatus and framework for running a deep neural network model according to embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and a computer program product) for performing part or all of the methods described herein. Such a program for implementing the present invention can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, or provided on a carrier signal, or in any other form.
[0142] It should be noted that the above embodiments illustrate the present invention rather than limit the present invention, and those skilled in the art can design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in the claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention can be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In the unit claims listing several devices, several of these devices can be embodied by the same item of hardware. The use of the words first, second, and third, etc. does not denote any order. These words can be interpreted as names.
Claims
1. A method for restoring factory settings, characterized in that, The method includes: Each time a target instruction is received, start timing from the time point when the target instruction is received, and detect whether the target instruction is received again within a target duration, where the target instruction is an instruction related to restoring the target device to factory settings; When it is detected that the target instruction is received again within the target duration, increment the value of the flag bit for restoring to factory settings by one; When it is determined that the current flag bit value reaches a first preset value, perform an operation to restore the target device to factory settings. The current flag bit value is used to reflect the degree of the user's requirement to restore the target device to factory settings; the first preset value is used to represent the boundary value of the degree of the user's requirement to restore the target device to factory settings; Starting from the time point when the target instruction is received, detecting whether the target instruction is received again within the target duration includes: Invoke a timer thread, where the timer thread is used to start timing from the time point when the target instruction is received and set the global variable value to a preset value when the timed duration reaches the target duration; When it is detected that the global variable value is the preset value, detect whether the target instruction received again is stored in a preset storage area; If it is detected that the target instruction received again is stored, determine that the target instruction is received again within the target duration.
2. The method according to claim 1, wherein The method further includes: when it is detected that the target instruction is not received again within the target duration, set the flag bit value to a second preset value.
3. The method according to claim 1, characterized in that, The method further includes: when it is determined that the current flag value does not reach the first preset value, start timing from the time point when the target instruction is received again, and detect whether the target instruction is received again within the target duration.
4. The method according to any one of claims 1 to 3, characterized in that Starting from the time point when the target instruction is received, detecting whether the target instruction is received again within the target duration includes: Starting from the time point, detect whether the target instruction is received again every preset duration; If it is detected that the target instruction is received again in the current detection, determine that the target instruction is received again within the target duration; If it is detected that the target instruction is not received again in the current detection, subtract the preset duration corresponding to the current detection from the target duration; If it is determined that the value after subtracting the preset duration corresponding to the current detection from the target duration is a target value, determine that the target instruction is not received again within the target duration.
5. The method according to any one of claims 1 to 3, characterized in that, Starting from the time point when the target instruction is received, detecting whether the target instruction is received again within the target duration includes: Set a timer based on the time point when the target instruction is received and the target duration; Loop to determine whether the timer has expired; If it is determined that the timer has expired, detect whether the target instruction received again is stored in a preset storage area; If it is detected that the target instruction received again is stored, determine that the target instruction is received again within the target duration.
6. The method according to any one of claims 1 to 3, characterized in that, Before receiving the target instruction, the method further includes: Add a flag bit to a target storage area of the target device; The flag value corresponding to the factory reset at the beginning.
7. The method according to any one of claims 1 to 3, characterized in that, The target instruction is a system startup instruction for a target device, and the flag value represents the number of times the target device has been started up; or, the target instruction is a factory reset instruction for the target device, and the flag value represents the number of times the factory reset instruction has been received.
8. A device for restoring factory settings, characterized in that, The device includes: A first detection unit, configured to start timing from the time point when a target instruction is received each time, and detect whether the target instruction is received again within a target duration, where the target instruction is an instruction related to the factory reset of the target device. Starting timing from the time point when the target instruction is received, detecting whether the target instruction is received again within the target duration includes: invoking a timer thread, where the timer thread is configured to start timing from the time point when the target instruction is received, and when the timed duration reaches the target duration, set a global variable value to a preset value; when detecting that the global variable value is the preset value, detect whether the target instruction received again is stored in a preset storage area; if it is detected that the target instruction received again is stored, determine that the target instruction is received again within the target duration; A second detection unit, configured to increment the flag value of the factory reset by one when it is detected that the target instruction is received again within the target duration; A processing unit, configured to perform a factory reset operation on the target device when it is determined that the current flag value reaches a first preset value, where the current flag value is used to reflect the user's demand degree for performing a factory reset on the target device; the first preset value is used to represent the boundary value of the user's demand degree for performing a factory reset on the target device.
9. A computer-readable storage medium, characterized in that, The storage medium includes a stored program, where when the program runs, it controls the device where the storage medium is located to execute the factory reset method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, The electronic device includes: A memory, configured to store a program; A processor, coupled to the memory, configured to run the program to execute the factory reset method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and system for restoring factory settings to prevent error operation
CN105046939A