Movatterモバイル変換


[0]ホーム

URL:


CN105159703B - The method and system of factory reset - Google Patents

The method and system of factory reset
Download PDF

Info

Publication number
CN105159703B
CN105159703BCN201510472653.4ACN201510472653ACN105159703BCN 105159703 BCN105159703 BCN 105159703BCN 201510472653 ACN201510472653 ACN 201510472653ACN 105159703 BCN105159703 BCN 105159703B
Authority
CN
China
Prior art keywords
restart
terminal device
factory settings
attribute value
restart reason
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201510472653.4A
Other languages
Chinese (zh)
Other versions
CN105159703A (en
Inventor
田小华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp LtdfiledCriticalGuangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN201510472653.4ApriorityCriticalpatent/CN105159703B/en
Publication of CN105159703ApublicationCriticalpatent/CN105159703A/en
Application grantedgrantedCritical
Publication of CN105159703BpublicationCriticalpatent/CN105159703B/en
Expired - Fee Relatedlegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Landscapes

Abstract

Translated fromChinese

本发明涉及一种恢复出厂设置的方法和系统,该方法包括如下步骤:在终端设备启动过程中的引导阶段,从存储单元读取字符串,并将所述字符串传递给内核阶段的命令行参数;所述字符串包括与用户输入的恢复指令相对应的重启原因参数;通过第一个用户进程读取所述命令行参数并将其写入属性值;当属性值等于所述重启原因参数时,调用与所述重启原因参数相对应的格式化接口函数对终端设备执行格式化操作。本发明通过在终端设备开机时识别重启原因参数判断是否为特殊重启原因,在执行init进程时执行相应的格式化操作,实现出厂设置地恢复。本发明无需用户进入Recovery模式操作,也无需用户多次重启,极大提高了恢复效率。

The present invention relates to a method and system for restoring factory settings. The method includes the following steps: in the booting phase of the terminal device startup process, reading a string from a storage unit, and passing the string to the command line in the kernel phase Parameter; the character string includes a restart reason parameter corresponding to the recovery instruction input by the user; the command line parameter is read by the first user process and written into an attribute value; when the attribute value is equal to the restart reason parameter , calling the format interface function corresponding to the restart reason parameter to perform a format operation on the terminal device. The present invention judges whether it is a special restart reason by identifying the restart reason parameter when the terminal device is turned on, and performs a corresponding formatting operation when executing the init process, so as to realize the restoration of factory settings. The present invention does not require the user to enter the Recovery mode for operation, nor does the user need to restart multiple times, which greatly improves the recovery efficiency.

Description

Translated fromChinese
恢复出厂设置的方法和系统Method and system for restoring factory settings

技术领域technical field

本发明涉及通信技术领域,特别是涉及一种恢复出厂设置的方法和系统。The invention relates to the field of communication technology, in particular to a method and system for restoring factory settings.

背景技术Background technique

出厂设置,指设备出厂时的默认状态,如默认的开始界面、待机方式、操作快捷键等。现在的Android终端设备(如手机、平板等)均有恢复出厂设置的功能,可以将终端设备的个性设置恢复到出厂时的默认状态,也就是格式化Data(数据)分区与Cache(缓存)分区,但在现有的恢复出厂设置的方法中,都要求Android终端设备先进入Recovery(恢复)模式,在Recovery模式下执行格式化操作,然后再重启终端设备完成开机,最终恢复出厂设置。这种方法要求用户多次重启设备,较为麻烦,且效率偏低。Factory settings refer to the default state of the device when it leaves the factory, such as the default start interface, standby mode, operation shortcut keys, etc. Today's Android terminal devices (such as mobile phones, tablets, etc.) have the function of restoring factory settings, which can restore the personality settings of the terminal device to the default state when leaving the factory, that is, format the Data (data) partition and Cache (cache) partition , but in the existing methods for restoring factory settings, all require the Android terminal device to first enter the Recovery (recovery) mode, perform formatting operations in the Recovery mode, then restart the terminal device to complete the boot, and finally restore the factory settings. This method requires the user to restart the device multiple times, which is troublesome and inefficient.

发明内容Contents of the invention

基于此,本发明为解决现有技术中的问题,提供一种恢复出厂设置的方法及系统,可以在终端设备的开机过程中完成格式化操作,从而恢复出厂设置,无需用户多次重启。Based on this, in order to solve the problems in the prior art, the present invention provides a method and system for restoring the factory settings, which can complete the formatting operation during the boot process of the terminal device, thereby restoring the factory settings without the need for the user to restart multiple times.

为实现上述目的,本发明实施例中采用如下技术方案:In order to achieve the above purpose, the following technical solutions are adopted in the embodiments of the present invention:

一种恢复出厂设置的方法,包括如下步骤:A method for restoring factory settings, comprising the steps of:

在终端设备启动过程中的引导阶段,从存储单元读取字符串,并将所述字符串传递给内核阶段的命令行参数;所述字符串包括与用户输入的恢复指令相对应的重启原因参数;In the boot phase of the terminal device startup process, read the string from the storage unit and pass the string to the command line parameters of the kernel phase; the string includes a restart reason parameter corresponding to the recovery command input by the user ;

通过第一个用户进程读取所述命令行参数并将其写入属性值;当属性值等于所述重启原因参数时,调用与所述重启原因参数相对应的格式化接口函数对终端设备执行格式化操作。Read the command line parameter through the first user process and write it into the attribute value; when the attribute value is equal to the restart reason parameter, call the formatting interface function corresponding to the restart reason parameter to execute on the terminal device Formatting operations.

相应的,本发明实施例中还提供一种恢复出厂设置的系统,包括:Correspondingly, an embodiment of the present invention also provides a system for restoring factory settings, including:

传递模块,用于在终端设备启动过程中的引导阶段,从存储单元读取字符串,并将所述字符串传递给内核阶段的命令行参数;所述字符串包括与用户输入的恢复指令相对应的重启原因参数;The transfer module is used to read the character string from the storage unit during the boot stage of the terminal device startup process, and pass the character string to the command line parameters of the kernel stage; the character string includes the recovery command input by the user. The corresponding restart reason parameter;

属性值写入模块,用于通过第一个用户进程读取所述命令行参数并将其写入属性值;An attribute value writing module, configured to read the command line parameters through the first user process and write them into the attribute value;

格式化模块,用于在属性值等于所述重启原因参数时,调用与所述重启原因参数相对应的格式化接口函数对终端设备执行格式化操作。The formatting module is configured to call a formatting interface function corresponding to the restart reason parameter to perform a formatting operation on the terminal device when the attribute value is equal to the restart reason parameter.

本发明通过在终端设备开机时识别重启原因参数判断是否为特殊重启原因(因恢复出厂设置而进行的重启),在执行第一个用户进程(init进程)时执行相应的格式化操作,实现出厂设置地恢复。本发明在终端设备的开机过程中完成格式化操作,从而恢复出厂设置,无需进入Recovery模式操作,也无需用户多次重启,极大提高了回复效率。The present invention judges whether it is a special restart reason (restart due to restoring factory settings) by identifying the restart reason parameter when the terminal device is turned on, and performs a corresponding formatting operation when executing the first user process (init process), so as to realize the factory Settings are restored. The present invention completes the formatting operation during the booting process of the terminal device, thereby restoring the factory settings, without entering into the Recovery mode operation, and without requiring the user to restart multiple times, which greatly improves the recovery efficiency.

附图说明Description of drawings

图1为本发明实施例一中恢复出厂设置的方法的流程示意图;FIG. 1 is a schematic flow diagram of a method for restoring factory settings in Embodiment 1 of the present invention;

图2为本发明实施例二中恢复出厂设置的方法的流程示意图;2 is a schematic flow diagram of a method for restoring factory settings in Embodiment 2 of the present invention;

图3为本发明实施例三中恢复出厂设置的系统的结构示意图。FIG. 3 is a schematic structural diagram of a system for restoring factory settings in Embodiment 3 of the present invention.

具体实施方式Detailed ways

下面结合较佳实施例和附图对本发明的内容作进一步详细说明。The content of the present invention will be further described in detail below in conjunction with preferred embodiments and accompanying drawings.

实施例一Embodiment one

如图1所示,本实施例提供一种恢复出厂设置的方法,包括如下步骤:As shown in Figure 1, this embodiment provides a method for restoring factory settings, including the following steps:

S11在终端设备启动过程中的引导阶段,从存储单元读取字符串,并将所述字符串传递给内核阶段的命令行参数;所述字符串包括与用户输入的恢复指令相对应的重启原因参数;S11 reads the character string from the storage unit during the boot stage of the terminal device startup process, and passes the character string to the command line parameter of the kernel stage; the character string includes the restart reason corresponding to the recovery instruction input by the user parameter;

S12通过第一个用户进程读取所述命令行参数并将其写入属性值;S12 reads the command line parameter through the first user process and writes it into the attribute value;

S13当属性值等于所述重启原因参数时,调用与所述重启原因参数相对应的格式化接口函数对终端设备执行格式化操作。S13 When the attribute value is equal to the restart reason parameter, call a formatting interface function corresponding to the restart reason parameter to perform a formatting operation on the terminal device.

具体的,以Android手机为例,在手机开机过程中,对于Android系统启动过程来说,可以划分成三个阶段:引导阶段(Bootloader阶段)、内核阶段(kernel阶段)、Android启动阶段,其中引导阶段可以将系统的软硬件环境带到一个合适状态,为运行操作系统做好准备。本发明为恢复手机的出厂设置,在手机启动过程中的引导阶段,从存储单元读取字符串,并将字符串传递给内核阶段(Kernel)的命令行参数command line,例如androidboot.mode=format。其中,所述字符串包括与用户输入的恢复指令相对应的重启原因参数,本实例中以format代表重启原因参数,该参数与用户输入的恢复指令相对应。在一种具体实施方式中,存储单元可为共享内存或某一特定的寄存器。Specifically, taking an Android mobile phone as an example, during the booting process of the mobile phone, for the Android system startup process, it can be divided into three stages: the boot stage (Bootloader stage), the kernel stage (kernel stage), and the Android startup stage. The stage can bring the software and hardware environment of the system to a suitable state, ready to run the operating system. The present invention is to restore the factory settings of the mobile phone. In the booting phase of the mobile phone startup process, the string is read from the storage unit, and the string is passed to the command line parameter command line of the kernel phase (Kernel), such as androidboot.mode=format . Wherein, the character string includes a restart reason parameter corresponding to the recovery command input by the user. In this example, format represents the restart reason parameter, and the parameter corresponds to the recovery command input by the user. In a specific implementation manner, the storage unit may be a shared memory or a specific register.

Kernel完成后会启动第一个用户进程,即init进程,当init进程运行时,通过执行一些管理任务来结束引导进程,例如检查文件系统、清理/tmp、启动各种服务等,本实施例在init进程执行初期读取命令行参数command line(如上述的androidboot.mode),然后将其写入属性值,例如ro.boot.mode=format。After the Kernel is completed, it will start the first user process, that is, the init process. When the init process is running, it will end the boot process by performing some management tasks, such as checking the file system, clearing /tmp, and starting various services. The init process reads the command line parameter command line (such as the above-mentioned androidboot.mode) at the initial stage of execution, and then writes it into an attribute value, such as ro.boot.mode=format.

具体的,在Android的属性系统中每个属性都有一个名称和值,他们都是字符串格式。属性被大量使用在Android系统中,用来记录系统设置或进程之间的信息交换。属性是在整个系统中全局可见的。每个进程可以获取或设置属性。在Android系统初始化时,Android将分配一个共享内存区来存储属性。这些是由init进程完成的,其源代码位于:device/system/init。init进程启动一个属性服务,属性服务在init进程中运行。本实施例将在init进程执行初期读取命令行参数,写入属性值。进一步的,本实施例在init进程执行时做一个格式化操作(对数据分区和/或缓存分区进行格式化)的借口,当属性值为重启原因参数format时,则调用格式化接口函数执行格式操作,格式化数据分区和/或缓存分区,实现出厂设置的恢复。由于init进程是第一个用户进程,在此进程进行格式化操作不会使后续进程运行出错,也就不会影响到手机Android系统的运行。Specifically, each attribute in Android's attribute system has a name and a value, and they are both in string format. Attributes are widely used in the Android system to record system settings or information exchange between processes. Properties are globally visible throughout the system. Each process can get or set attributes. When the Android system is initialized, Android will allocate a shared memory area to store attributes. These are done by the init process, whose source code is located at: device/system/init. The init process starts a property service, and the property service runs in the init process. In this embodiment, command line parameters are read and property values are written in the initial stage of init process execution. Further, this embodiment is an excuse to perform a format operation (format the data partition and/or cache partition) when the init process is executed. When the attribute value is the restart reason parameter format, the format interface function is called to execute the format Operation, format the data partition and/or cache partition, and restore the factory settings. Since the init process is the first user process, formatting operations in this process will not cause errors in the operation of subsequent processes, and will not affect the operation of the Android system of the mobile phone.

如上所述,本实施例提供了一种新颖的恢复出厂设置的方法,利用重启原因参数识别特殊的重启原因,判断是否进行恢复出厂设置,若是,则在终端设备的开机过程中,在执行init进程时完成格式化操作,实现出厂设置的恢复。采用本实施例提供的恢复出厂设置的方法,用户无需进入Recovery模式操作,也无需用户多次重启终端设备,极大提高了恢复效率。As mentioned above, this embodiment provides a novel method of restoring factory settings, which uses the restart reason parameter to identify a special restart reason, and judges whether to restore factory settings. The formatting operation is completed during the process, and the factory settings are restored. By adopting the method for restoring factory settings provided in this embodiment, the user does not need to enter the Recovery mode for operation, nor does the user need to restart the terminal device multiple times, which greatly improves the recovery efficiency.

实施例二Embodiment two

本实施例结合一个详细的恢复出厂设置的过程来进一步说明本发明的有益效果。This embodiment further illustrates the beneficial effects of the present invention in combination with a detailed process of restoring factory settings.

如图2所示,本实施例提供的恢复出厂设置的方法由用户输入恢复指令后触发,该方法包括如下步骤:As shown in Figure 2, the method for restoring factory settings provided by this embodiment is triggered after the user inputs a restore command, and the method includes the following steps:

S21终端设备接收恢复指令后,调用电源管理的重启方法,写入与所述恢复指令对应的重启原因参数;S21 After receiving the recovery instruction, the terminal device invokes the restart method of power management, and writes the restart reason parameter corresponding to the recovery instruction;

S22在终端设备关机过程中的内核阶段,将所述重启原因参数转化为字符串,并将所述字符串写入存储单元;S22, at the kernel stage during the shutdown process of the terminal device, convert the restart reason parameter into a character string, and write the character string into the storage unit;

S23在终端设备启动过程中的引导阶段,从存储单元读取字符串,并将该字符串传递给内核阶段的命令行参数;S23 reads the character string from the storage unit during the boot stage of the terminal device startup process, and passes the character string to the command line parameter of the kernel stage;

S24通过第一个用户进程读取命令行参数并将其写入属性值;S24 reads the command line parameters and writes them to the attribute value through the first user process;

S25判断属性值是否等于重启原因参数,若是,则进入S26;若否,则正常开机;S25 judges whether the attribute value is equal to the restart reason parameter, if so, then enters S26; if not, then normally boots;

S26调用与重启原因参数相对应的格式化接口函数对终端设备执行格式化操作。S26 calls the format interface function corresponding to the restart reason parameter to perform a format operation on the terminal device.

仍以Android手机为例,出于某种原因用户有必要恢复出厂设置时,例如手机内存使用占比较大、内存不足导致手机运行较慢,或者手机经常死机时,都需要恢复出厂设置。此时,用户可以依据手机提供的输入界面输入恢复指令,手机在接收恢复指令后,进行关机重启,并在重启过程中恢复出厂设置。具体为,手机接收恢复指令后,调用电源管理(PowerManager)的重启方法(reboot方法),并写入与恢复指令相对应的重启原因参数format,然后手机关机,在关机过程中的kernel阶段,将重启原因参数format转换为一个字符串(可将其称之为魔幻数),并将其写入存储单元,例如写入共享内存或某个特定寄存器中。Still taking an Android mobile phone as an example, when the user needs to restore the factory settings for some reason, such as a large proportion of the phone’s memory usage, insufficient memory causing the phone to run slowly, or the phone often crashes, it is necessary to restore the factory settings. At this point, the user can input a recovery command according to the input interface provided by the mobile phone. After receiving the recovery command, the mobile phone will be shut down and restarted, and the factory settings will be restored during the restart process. Specifically, after the mobile phone receives the recovery command, it calls the restart method (reboot method) of the power management (PowerManager), and writes the restart reason parameter format corresponding to the recovery command, and then shuts down the mobile phone. During the kernel stage of the shutdown process, the The restart reason parameter format is converted into a character string (it can be called a magic number), and written into a storage unit, such as a shared memory or a specific register.

手机关机后立即重启,在启动过程中的引导阶段,从存储单元读取魔幻数(即上述的字符串),并将其传递到kernel的命令行参数command line,如androidboot.mode=format。kernel完成后会启动init进程,该进程为第一个用户进程,在init进程执行初期读取命令行参数androidboot.mode,写入属性值,如ro.boot.mode=format。然后在init进程执行阶段,对属性值进行判断,如上述属性值为format时,则调用格式化接口函数执行格式操作,进而恢复出厂设置。而在正常开机时,init进程执行时由于属性值不等于format,故不会对数据分区和缓存分区进行格式化操作,不影响用户使用手机。Immediately restart the mobile phone after shutting down, and in the booting phase of the startup process, read the magic number (ie the above-mentioned character string) from the storage unit, and pass it to the command line parameter command line of the kernel, such as androidboot.mode=format. After the kernel is completed, the init process will be started. This process is the first user process. At the initial stage of the init process, the command line parameter androidboot.mode is read and the attribute value is written, such as ro.boot.mode=format. Then, in the execution stage of the init process, the attribute value is judged. If the above attribute value is format, the format interface function is called to perform the format operation, and then the factory settings are restored. When starting up normally, because the attribute value is not equal to format when the init process is executed, the data partition and cache partition will not be formatted, which will not affect the user's use of the mobile phone.

较佳地,考虑到用户有时不需要将所有的设置内容全部恢复到出厂设置状态,因此,本实施例根据用户输入的不同恢复指令来格式化不同的分区,以实现将部分设置内容恢复到出厂设置状态。Preferably, considering that the user sometimes does not need to restore all the settings to the factory settings, this embodiment formats different partitions according to different recovery instructions input by the user, so as to restore part of the settings to the factory settings. Set state.

在一种具体实施方式中,恢复指令包括数据(Data)分区恢复指令和缓存(Cache)分区恢复指令。In a specific implementation manner, the restoration instruction includes a data (Data) partition restoration instruction and a cache (Cache) partition restoration instruction.

当用户向手机输入数据分区恢复指令后,手机按照上述方法,调用PowerManager的reboot方法,写入与数据分区恢复指令对应的重启原因参数;然后在手机关机过程中的内核阶段,将与数据分区恢复指令对应的重启原因参数转化为字符串,并将字符串写入存储单元。在手机启动过程中的引导阶段,从存储单元读取字符串,并将该字符串传递给内核阶段的命令行参数,然后通过init进程读取命令行参数并将其写入属性值;此时属性值等于与数据分区恢复指令对应的重启原因参数,于是调用对应的格式化接口函数对手机的数据分区执行格式化操作,恢复数据分区的出厂设置。After the user enters the data partition recovery command to the mobile phone, the mobile phone calls the reboot method of PowerManager according to the above method, and writes the restart reason parameter corresponding to the data partition recovery command; The restart reason parameter corresponding to the instruction is converted into a character string, and the character string is written into the storage unit. In the boot stage of the mobile phone startup process, read the character string from the storage unit, and pass the character string to the command line parameter of the kernel stage, and then read the command line parameter through the init process and write it into the attribute value; at this time The attribute value is equal to the restart reason parameter corresponding to the data partition recovery instruction, so the corresponding formatting interface function is called to perform a formatting operation on the data partition of the mobile phone, and restore the factory settings of the data partition.

同理,当用户向手机输入缓存分区恢复指令后,手机先关机然后再启动,在启动过程中执行init进程时,调用相应的格式化接口函数,对手机的缓存分区进行格式化操作,恢复缓存分区的出厂设置。Similarly, when the user enters the cache partition restore command to the mobile phone, the mobile phone is shut down and then restarted. When the init process is executed during the startup process, the corresponding format interface function is called to format the cache partition of the mobile phone and restore the cache. The factory settings for the partition.

另外,手机还可以提供更多不同的输入选项,以便用户输入更多不同的恢复指令,使数据分区中部分设置内容恢复到出厂设置状态,以便用户有选择地保留部分设置内容,满足用户不同层次的需求。In addition, the mobile phone can also provide more and different input options, so that the user can input more and different recovery instructions, so that some settings in the data partition can be restored to the factory settings, so that the user can selectively retain some settings, and satisfy users at different levels. demand.

上述实施例均以手机为例,但其他如平板、机顶盒等终端设备均能实施本发明提供的恢复出厂设置的方法,因此不能以此来限制本发明的保护范围。The above-mentioned embodiments all take mobile phones as examples, but other terminal devices such as tablets and set-top boxes can implement the method for restoring factory settings provided by the present invention, so the protection scope of the present invention cannot be limited by this.

综上所述,本实施例提供的恢复出厂设置的方法,根据用户输入的不同恢复指令生成相应的重启原因参数,利用重启原因参数判断对哪些分区或哪些设置内容进行恢复,在终端设备开机执行init进程时完成相应分区的格式化操作,将部分设置内容恢复至出厂设置状态。采用本实施例提供的恢复出厂设置的方法,用户无需进入Recovery模式操作,也无需用户多次重启终端设备,极大提高了恢复效率,且在恢复出厂设置时,用户可以有选择地保留部分设置内容,满足用户不同层次的需求。To sum up, the method for restoring factory settings provided by this embodiment generates corresponding restart reason parameters according to different restore commands input by the user, uses the restart reason parameters to determine which partitions or which settings are to be restored, and executes when the terminal device is powered on Complete the formatting operation of the corresponding partition during the init process, and restore some settings to the factory settings. By adopting the method for restoring factory settings provided in this embodiment, the user does not need to enter the Recovery mode for operation, nor does the user need to restart the terminal device multiple times, which greatly improves the recovery efficiency, and when restoring the factory settings, the user can selectively retain some settings content to meet the needs of different levels of users.

实施例三Embodiment Three

本实施例提供一种恢复出厂设置的系统,如图3所示,包括:This embodiment provides a system for restoring factory settings, as shown in Figure 3, including:

传递模块10,用于在终端设备启动过程中的引导阶段,从存储单元读取字符串,并将所述字符串传递给内核阶段的命令行参数;所述字符串包括与用户输入的恢复指令相对应的重启原因参数;The transfer module 10 is used to read the character string from the storage unit during the boot stage of the terminal device startup process, and pass the character string to the command line parameter of the kernel stage; the character string includes the recovery command input by the user The corresponding restart reason parameter;

属性值写入模块20,用于通过第一个用户进程读取所述命令行参数并将其写入属性值;Attribute value writing module 20, is used for reading described command line parameter by first user process and writes it into attribute value;

格式化模块30,用于在属性值等于所述重启原因参数时,调用与所述重启原因参数相对应的格式化接口函数对终端设备执行格式化操作。The formatting module 30 is configured to call a formatting interface function corresponding to the restarting reason parameter to perform a formatting operation on the terminal device when the attribute value is equal to the restarting reason parameter.

在终端设备开机过程中,在Android系统运行之前有一个引导阶段,该引导阶段可以将系统的软硬件环境带到一个合适状态,为运行操作系统做好准备。为恢复终端设备的出厂设置,本实施例在终端设备启动过程中的引导阶段,利用传递模块10从存储单元读取字符串,并将字符串传递给内核阶段(Kernel)的命令行参数command line,例如androidboot.mode=format。其中,所述字符串包括与用户输入的恢复指令相对应的重启原因参数,本实例中以format代表重启原因参数,该参数与用户输入的恢复指令相对应。在一种具体实施方式中,上述存储单元可为共享内存或某一特定的寄存器。During the boot process of the terminal device, there is a boot stage before the Android system runs, which can bring the system's software and hardware environment to a suitable state and prepare for running the operating system. In order to restore the factory settings of the terminal device, the present embodiment uses the transmission module 10 to read the character string from the storage unit during the boot phase of the terminal device startup process, and the character string is passed to the command line parameter command line of the kernel stage (Kernel). , such as androidboot.mode=format. Wherein, the character string includes a restart reason parameter corresponding to the recovery command input by the user. In this example, format represents the restart reason parameter, and the parameter corresponds to the recovery command input by the user. In a specific implementation manner, the above-mentioned storage unit may be a shared memory or a specific register.

Kernel完成后会启动第一个用户进程,即init进程,当init进程运行时,通过执行一些管理任务来结束引导进程,例如检查文件系统、清理/tmp、启动各种服务等,本实施例通过属性值写入模块20,在init进程执行初期读取命令行参数command line(如上述的androidboot.mode),然后将其写入属性值,例如ro.boot.mode=format。具体的,在Android的属性系统中每个属性都有一个名称和值,他们都是字符串格式。属性被大量使用在Android系统中,用来记录系统设置或进程之间的信息交换。属性是在整个系统中全局可见的。每个进程可以获取或设置属性。在Android系统初始化时,Android将分配一个共享内存区来存储属性。这些是由init进程完成的,其源代码位于:device/system/init。init进程启动一个属性服务,属性服务在init进程中运行。本实施例将在init进程执行初期读取命令行参数,写入属性值。进一步的,本实施例在init进程执行时通过格式化模块30做一个格式化操作的借口,当属性值为重启原因参数format时,调用格式化接口函数执行格式操作,格式化数据分区和/或缓存分区,实现出厂设置的恢复。After the Kernel is completed, it will start the first user process, that is, the init process. When the init process is running, it will end the boot process by performing some management tasks, such as checking the file system, clearing /tmp, and starting various services. The attribute value writing module 20 reads the command line parameter command line (such as the above-mentioned androidboot.mode) at the initial stage of init process execution, and then writes it into the attribute value, such as ro.boot.mode=format. Specifically, each attribute in Android's attribute system has a name and a value, and they are both in string format. Attributes are widely used in the Android system to record system settings or information exchange between processes. Properties are globally visible throughout the system. Each process can get or set attributes. When the Android system is initialized, Android will allocate a shared memory area to store attributes. These are done by the init process, whose source code is located at: device/system/init. The init process starts a property service, and the property service runs in the init process. In this embodiment, command line parameters are read and property values are written in the initial stage of init process execution. Further, in this embodiment, when the init process is executed, the formatting module 30 is used as an excuse for a formatting operation. When the attribute value is the restart reason parameter format, the formatting interface function is called to perform the formatting operation, and the data partition and/or Cache partition to restore factory settings.

在一种具体实施方式中,如图3所示,本发明的恢复出厂设置的系统还包括:In a specific implementation manner, as shown in Figure 3, the system for restoring factory settings of the present invention also includes:

重启原因写入模块40,用于在接收恢复指令后,调用电源管理的重启方法,写入与所述恢复指令对应的重启原因参数;The restart reason writing module 40 is used to call the restart method of power management after receiving the recovery instruction, and write the restart reason parameter corresponding to the recovery instruction;

转换模块50,用于在终端设备关机过程中的内核阶段,将所述重启原因参数转化为字符串,并将字符串写入存储单元。The conversion module 50 is configured to convert the restart reason parameter into a character string at the kernel stage in the shutdown process of the terminal device, and write the character string into the storage unit.

用户可以依据终端设备提供的输入界面输入恢复指令,终端设备在接收恢复指令后,进行关机重启,并在重启过程中恢复出厂设置。具体为,终端设备的重启原因写入模块40在接收恢复指令后,调用电源管理(PowerManager)的reboot方法,写入与恢复指令相对应的重启原因参数format,然后终端设备关机,在关机过程中的kernel阶段,转换模块50将重启原因参数format转换为一个字符串,并将其写入存储单元,例如写入共享内存或某个特定寄存器中。终端设备关机后立即重启,在启动过程中的引导阶段,传递模块10从存储单元读取上述的字符串,并将其传递到kernel的命令行参数command line,如androidboot.mode=format。kernel完成后会启动init进程,该进程为第一个用户进程,在init进程执行初期通过属性值写入模块20读取命令行参数androidboot.mode,写入属性值,如ro.boot.mode=format。然后通过格式化模块30在init进程执行阶段对属性值进行判断,如上述属性值为format时,则格式化模块30调用格式化接口函数执行格式操作,进而恢复出厂设置。而在正常开机时,init进程执行时由于属性值不等于format,故格式化模块30不会对数据分区和缓存分区进行格式化操作,不影响终端设备的使用。The user can input the recovery command according to the input interface provided by the terminal device. After receiving the recovery command, the terminal device will shut down and restart, and restore the factory settings during the restart process. Specifically, the restart reason writing module 40 of the terminal device calls the reboot method of the power management (PowerManager) after receiving the recovery command, writes the restart reason parameter format corresponding to the recovery command, and then the terminal device is shut down. In the kernel stage, the conversion module 50 converts the restart reason parameter format into a character string, and writes it into a storage unit, such as a shared memory or a specific register. After the terminal device is shut down, it is restarted immediately. In the booting phase of the startup process, the transmission module 10 reads the above-mentioned character string from the storage unit, and transmits it to the command line parameter command line of the kernel, such as androidboot.mode=format. After the kernel is completed, the init process will be started. This process is the first user process. At the initial stage of the init process, the attribute value write module 20 reads the command line parameter androidboot.mode and writes the attribute value, such as ro.boot.mode= format. Then the attribute value is judged by the format module 30 in the execution stage of the init process. If the above attribute value is format, the format module 30 calls the format interface function to execute the format operation, and then restores the factory settings. And when starting up normally, because the attribute value is not equal to format when the init process is executed, the formatting module 30 will not format the data partition and cache partition, which will not affect the use of the terminal device.

在一种具体实施方式中,上述恢复指令包括数据分区恢复指令和缓存分区恢复指令。In a specific implementation manner, the restoration instruction includes a data partition restoration instruction and a cache partition restoration instruction.

在一种具体实施方式中,若属性值等于与数据分区恢复指令相对应的重启原因参数,则格式化模块30调用格式化接口函数对终端设备的数据分区进行格式化操作;In a specific implementation manner, if the attribute value is equal to the restart reason parameter corresponding to the data partition recovery instruction, then the formatting module 30 calls the formatting interface function to format the data partition of the terminal device;

在一种具体实施方式中,若属性值等于与缓存分区恢复指令相对应的重启原因参数,则格式化模块30调用格式化接口函数对终端设备的缓存分区进行格式化操作。In a specific implementation manner, if the attribute value is equal to the restart reason parameter corresponding to the cache partition recovery instruction, the formatting module 30 calls the formatting interface function to format the cache partition of the terminal device.

上述各模块其功能的具体实现方法可参照实施例一和实施例二中提供的具体方法,此处不在进行赘述。For the specific implementation methods of the functions of the above modules, refer to the specific methods provided in Embodiment 1 and Embodiment 2, which will not be repeated here.

以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The various technical features of the above-mentioned embodiments can be combined arbitrarily. To make the description concise, all possible combinations of the various technical features in the above-mentioned embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, should be considered as within the scope of this specification.

以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several implementation modes of the present invention, and the descriptions thereof are relatively specific and detailed, but should not be construed as limiting the patent scope of the invention. It should be pointed out that those skilled in the art can make several modifications and improvements without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent for the present invention should be based on the appended claims.

Claims (10)

Translated fromChinese
1.一种恢复出厂设置的方法,其特征在于,包括如下步骤:1. A method for restoring factory settings, comprising the steps of:在终端设备启动过程中的引导阶段,从存储单元读取字符串,并将所述字符串传递给内核阶段的命令行参数;所述字符串包括与用户输入的恢复指令相对应的重启原因参数;In the boot phase of the terminal device startup process, read the string from the storage unit and pass the string to the command line parameters of the kernel phase; the string includes a restart reason parameter corresponding to the recovery command input by the user ;通过第一个用户进程读取所述命令行参数并将其写入属性值;当所述属性值等于所述重启原因参数时,调用与所述重启原因参数相对应的格式化接口函数对所述终端设备执行格式化操作。Read the command line parameter through the first user process and write it into the attribute value; when the attribute value is equal to the restart reason parameter, call the formatting interface function corresponding to the restart reason parameter to the The above-mentioned terminal device executes the formatting operation.2.根据权利要求1所述的恢复出厂设置的方法,其特征在于,还包括如下步骤:2. The method for restoring factory settings according to claim 1, further comprising the steps of:终端设备接收恢复指令后,调用电源管理的重启方法,写入与所述恢复指令对应的重启原因参数;After receiving the recovery instruction, the terminal device invokes the restart method of power management, and writes the restart reason parameter corresponding to the recovery instruction;在终端设备关机过程中的内核阶段,将所述重启原因参数转化为所述字符串,并将所述字符串写入所述存储单元。In the kernel stage during the shutdown process of the terminal device, the restart reason parameter is converted into the character string, and the character string is written into the storage unit.3.根据权利要求1或2所述的恢复出厂设置的方法,其特征在于,所述存储单元包括共享内存或寄存器。3. The method for restoring factory settings according to claim 1 or 2, wherein the storage unit includes a shared memory or a register.4.根据权利要求1或2所述的恢复出厂设置的方法,其特征在于,所述恢复指令包括数据分区恢复指令和缓存分区恢复指令。4. The method for restoring factory settings according to claim 1 or 2, wherein the restoration instruction includes a data partition restoration instruction and a cache partition restoration instruction.5.根据权利要求4所述的恢复出厂设置的方法,其特征在于,还包括下列各项中的任一项:5. The method for restoring factory settings according to claim 4, further comprising any one of the following items:若属性值等于与所述数据分区恢复指令相对应的重启原因参数,则调用格式化接口函数对终端设备的数据分区进行格式化操作;If the attribute value is equal to the restart reason parameter corresponding to the data partition recovery instruction, then call the formatting interface function to format the data partition of the terminal device;若属性值等于与所述缓存分区恢复指令相对应的重启原因参数,则调用格式化接口函数对终端设备的缓存分区进行格式化操作。If the attribute value is equal to the restart reason parameter corresponding to the cache partition recovery instruction, the format interface function is called to format the cache partition of the terminal device.6.一种恢复出厂设置的系统,其特征在于,包括:6. A system for restoring factory settings, comprising:传递模块,用于在终端设备启动过程中的引导阶段,从存储单元读取字符串,并将所述字符串传递给内核阶段的命令行参数;所述字符串包括与用户输入的恢复指令相对应的重启原因参数;The transfer module is used to read the character string from the storage unit during the boot stage of the terminal device startup process, and pass the character string to the command line parameters of the kernel stage; the character string includes the recovery command input by the user. The corresponding restart reason parameter;属性值写入模块,用于通过第一个用户进程读取所述命令行参数并将其写入属性值;An attribute value writing module, configured to read the command line parameters through the first user process and write them into the attribute value;格式化模块,用于在所述属性值等于所述重启原因参数时,调用与所述重启原因参数相对应的格式化接口函数对所述终端设备执行格式化操作。A formatting module, configured to call a formatting interface function corresponding to the restart reason parameter to perform a formatting operation on the terminal device when the attribute value is equal to the restart reason parameter.7.根据权利要求6所述的恢复出厂设置的系统,其特征在于,还包括:7. The system for restoring factory settings according to claim 6, further comprising:重启原因写入模块,用于在接收恢复指令后,调用电源管理的重启方法,写入与所述恢复指令对应的重启原因参数;The restart reason writing module is used to call the restart method of power management after receiving the recovery command, and write the restart reason parameter corresponding to the recovery command;转换模块,用于在终端设备关机过程中的内核阶段,将所述重启原因参数转化为所述字符串,并将所述字符串写入所述存储单元。The conversion module is configured to convert the restart reason parameter into the character string at the kernel stage in the shutdown process of the terminal device, and write the character string into the storage unit.8.根据权利要求6或7所述的恢复出厂设置的系统,其特征在于,所述存储单元包括共享内存或寄存器。8. The system for restoring factory settings according to claim 6 or 7, wherein the storage unit comprises a shared memory or a register.9.根据权利要求6或7所述的恢复出厂设置的系统,其特征在于,所述恢复指令包括数据分区恢复指令和缓存分区恢复指令。9. The system for restoring factory settings according to claim 6 or 7, wherein the restoration instruction includes a data partition restoration instruction and a cache partition restoration instruction.10.根据权利要求9所述的恢复出厂设置的系统,其特征在于,若属性值等于与所述数据分区恢复指令相对应的重启原因参数,则所述格式化模块调用格式化接口函数对终端设备的数据分区进行格式化操作;10. The system for restoring factory settings according to claim 9, wherein if the attribute value is equal to the restart reason parameter corresponding to the data partition recovery instruction, then the formatting module calls the formatting interface function to the terminal Format the data partition of the device;和/或and / or若属性值等于与所述缓存分区恢复指令相对应的重启原因参数,则所述格式化模块调用格式化接口函数对终端设备的缓存分区进行格式化操作。If the attribute value is equal to the restart reason parameter corresponding to the cache partition recovery instruction, the formatting module calls a formatting interface function to format the cache partition of the terminal device.
CN201510472653.4A2015-08-042015-08-04The method and system of factory resetExpired - Fee RelatedCN105159703B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201510472653.4ACN105159703B (en)2015-08-042015-08-04The method and system of factory reset

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201510472653.4ACN105159703B (en)2015-08-042015-08-04The method and system of factory reset

Publications (2)

Publication NumberPublication Date
CN105159703A CN105159703A (en)2015-12-16
CN105159703Btrue CN105159703B (en)2018-06-05

Family

ID=54800568

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201510472653.4AExpired - Fee RelatedCN105159703B (en)2015-08-042015-08-04The method and system of factory reset

Country Status (1)

CountryLink
CN (1)CN105159703B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN105975037A (en)*2016-05-162016-09-28青岛海信电器股份有限公司Method for restoring factory settings based on Android system and intelligent equipment
CN106445719A (en)*2016-09-262017-02-22青岛海信移动通信技术股份有限公司Recovery-mode Recovery instruction reading and writing method and device
CN112068987B (en)*2019-06-102024-08-23海信视像科技股份有限公司Method and device for quickly restoring factory settings
CN112579348A (en)*2019-09-292021-03-30北京君正集成电路股份有限公司Method for restoring factory settings by counting system starting times
CN111625385B (en)*2020-05-252024-12-17广东小天才科技有限公司Method, system, terminal equipment and storage medium for adjusting RPM to deal with dead halt
CN113505105B (en)*2021-06-232025-02-14惠州Tcl云创科技有限公司 Method, device, mobile terminal and medium for restoring factory settings of mobile terminal

Citations (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102802083A (en)*2012-08-242012-11-28乐视网信息技术(北京)股份有限公司Set top box updating method based on Android system and set top box
CN103514013A (en)*2013-09-112014-01-15深圳市共进电子股份有限公司Gateway product FLASH configuration loss processing method
CN103853584A (en)*2014-01-172014-06-11深圳市同洲电子股份有限公司Master system recovery method and terminal
CN103927239A (en)*2014-03-282014-07-16深圳市江波龙电子有限公司Method and device for restoring system of terminal equipment
CN104156273A (en)*2014-07-302014-11-19深圳市中兴移动通信有限公司System exception repair method, system exception repair device and mobile terminal
CN104166599A (en)*2014-07-102014-11-26汉柏科技有限公司Method for recovering delivery configuration by restarting ARM device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
JP3925611B2 (en)*2001-03-222007-06-06セイコーエプソン株式会社 Information providing system, information providing apparatus, program, information storage medium, and user interface setting method
US7024672B2 (en)*2002-06-262006-04-04Microsoft CorporationProcess-mode independent driver model

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102802083A (en)*2012-08-242012-11-28乐视网信息技术(北京)股份有限公司Set top box updating method based on Android system and set top box
CN103514013A (en)*2013-09-112014-01-15深圳市共进电子股份有限公司Gateway product FLASH configuration loss processing method
CN103853584A (en)*2014-01-172014-06-11深圳市同洲电子股份有限公司Master system recovery method and terminal
CN103927239A (en)*2014-03-282014-07-16深圳市江波龙电子有限公司Method and device for restoring system of terminal equipment
CN104166599A (en)*2014-07-102014-11-26汉柏科技有限公司Method for recovering delivery configuration by restarting ARM device
CN104156273A (en)*2014-07-302014-11-19深圳市中兴移动通信有限公司System exception repair method, system exception repair device and mobile terminal

Also Published As

Publication numberPublication date
CN105159703A (en)2015-12-16

Similar Documents

PublicationPublication DateTitle
CN105159703B (en)The method and system of factory reset
CN102236621B (en)Computer interface information configuration system and method
CN108614718B (en) Method, device and implementing device for starting operating system
CN103399840B (en)The outer amending method of the band of a kind of allocation of computer file and computer
CN100377085C (en) Implementation Method of Embedded Operating System Hardware Image Boot Optimization
US10642623B1 (en)Preserving firmware settings during firmware updates
US9021436B2 (en)Automatic reconnection of debugger to a reactivated application
US20130111202A1 (en)Method and device for cold starting android mobile terminal
KR101673299B1 (en)Operating system recovery method and apparatus, and terminal device
WO2018040494A1 (en)Method and device for extending processor instruction set
US20170337064A1 (en)System and method for booting an information handling system
CN115951949A (en) Method, device and computing device for recovering configuration parameters of BIOS
CN110262838A (en)A kind of processing method of program crashing, device, terminal and storage medium
CN106569854A (en)Method and system for setting device firmware and realizing factory testing
CN103197964A (en)Method for exchanging information among multiple operating systems of electronic device
CN111381892B (en)Data processing method, device, equipment and machine-readable medium
CN110399168A (en) System startup method, device and equipment for multi-data disk storage server
CN113778485B (en) System operation method and device of electronic chip, electronic chip and storage medium
US9852029B2 (en)Managing a computing system crash
CN102043670A (en) How to switch between different operating systems on a computer
US20090265537A1 (en)Computer system, bios structure and boot method thereof
CN115658152A (en)Firmware upgrading method, firmware, electronic device and computer readable storage medium
CN114924802A (en)System starting method, device equipment and medium based on BMC and BIOS
CN114721918A (en) A stress test method, device, electronic device and storage medium
CN115373901A (en)Terminal data recovery method, device, equipment and storage medium

Legal Events

DateCodeTitleDescription
C06Publication
PB01Publication
C10Entry into substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant
CP01Change in the name or title of a patent holder

Address after:Changan town in Guangdong province Dongguan 523860 usha Beach Road No. 18

Patentee after:GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd.

Address before:Changan town in Guangdong province Dongguan 523860 usha Beach Road No. 18

Patentee before:GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd.

CP01Change in the name or title of a patent holder
CF01Termination of patent right due to non-payment of annual fee

Granted publication date:20180605

CF01Termination of patent right due to non-payment of annual fee

[8]ページ先頭

©2009-2025 Movatter.jp