How to capture System Recovery factory setup events in Android

Source: Internet
Author: User

Click to restore factory settings, the system restart, once again into the system, all the data are emptied, how can we know before the end of the factory to restore the set up? How can I mark the recovery of a factory setup event? I hope that after the system restart, according to customer needs, to determine just restore the factory settings, and then add some response and processing, but also different from the normal boot or restart, how to do?

First encountered this problem, I was at a loss, just a rough guess should be in the Bootloarder operation capture tag, should be very troublesome, so sent a post to ask.

A friend offered program a:

This to modify the bootable under the Recovery.c file, let him erase the Usrdata partition, then add a logo file in the cache partition. My advice is to restore the factory settings will be in the cache partition under the recovery log files, you can immediately read the boot file, as a what, such as Android run up will empty cache/recovery/log files, so in due course to do processing.

The theory is correct for this method. I do experiments on the real machine, after the boot, must be very quick skill, quickly copy the Cache/recovery/log out of the Android system before running, to complete this operation. But it didn't do what I wanted, because, in order to meet the customer's requirements, to improve the startup rate and reduce the time it took to format the cache before entering the system, our engineers modified it. Limit the power-on boot to the cache write, even if the factory settings to restore, will not create a recovery directory, there will be no log files.

Although the plan was defeated, fortunately, another friend offered the Plan B:

Generally after the first boot or do factory reset, will certainly report this error:

W/entropyservice (761): Unable to load initial entropy (boot?)

W/entropyservice (761): java.io.FileNotFoundException:/data/system/entropy.dat (No such file or directory)

W/entropyservice (761): At Org.apache.harmony.luni.platform.OSFileSystem.openImpl (Native method)

W/entropyservice (761): at Org.apache.harmony.luni.platform.OSFileSystem.open (osfilesystem.java:152)

W/entropyservice (761): at Java.io.fileinputstream.<init> (fileinputstream.java:82)

W/entropyservice (761): at Java.io.fileinputstream.<init> (fileinputstream.java:134)

W/entropyservice (761): at Com.android.server.RandomBlock.fromFile (randomblock.java:45)

W/entropyservice (761): at Com.android.server.EntropyService.loadInitialEntropy (entropyservice.java:99)

W/entropyservice (761): at Com.android.server.entropyservice.<init> (entropyservice.java:86)

W/entropyservice (761): at Com.android.server.entropyservice.<init> (entropyservice.java:76)

W/entropyservice (761): at Com.android.server.ServerThread.run (systemserver.java:109)

Specific to the code is entropyservice:

private void Loadinitialentropy () {  
        try {  
            randomblock.fromfile (entropyfile). ToFile (Randomdevice);  
        } catch (IOException e) {  
            SLOG.W (TAG, "Unable to load initial entropy (boot?)", E);  
        }  
    

Adding the processing you want to do in the catch is fine. A special note: This is Android's first service, if the processing is more complex, to use other Android services, or recommend to only set a flag here (such as creating a temporary file), put it before processing.

This method is simple and easy to operate, and in the system normal boot or normal reboot, Entropyservice will never complain (W or E), really achieve the mark to restore the factory settings.

I ask the question post in: http://topic.csdn.net/u/20110427/14/4df32953-fec5-44c0-8847-375b5a44bee8.html

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.