Skip to content

Restoring Your Android Device from Factory Mode

Screenshot

Have you found yourself trapped in the SetupWizard activity on your Android device, unable to proceed or exit? This comprehensive guide provides a step-by-step solution to restore your device to its normal state and overcome the constraints of the SetupWizard activity using ADB commands and system settings manipulation.

The SetupWizard activity is designed to guide users through the initial setup process on Android devices. However, getting stuck in this mode can be frustrating, preventing you from accessing your device's full functionality. Fortunately, with the power of ADB commands and system settings manipulation, you have the means to break free from the SetupWizard activity and restore your device to its default state.

In this comprehensive guide, you will learn how to leverage the power of ADB to restore your Android device from factory mode. By following the step-by-step instructions and utilizing ADB commands and system settings manipulation, you can regain control over your device and return it to its default state.

Understanding Factory Mode

Factory mode is a diagnostic mode available on Android devices that provides extensive testing and debugging options. It is typically used by manufacturers and developers during the production and quality assurance phases. However, getting stuck in factory mode can disrupt normal device functionality and limit your ability to use your Android device effectively.

Launching SetupWizardTestActivity

To initiate the restoration process, we can use the SetupWizardTestActivity to trigger the factory mode on your device. Connect your Android device to a computer with ADB (Android Debug Bridge) installed and execute the following command:

adb shell su -c am start -n com.google.android.setupwizard/.SetupWizardTestActivity

You might have noticed that some devices will not just work to kill or stop the services and this guide is for everyone that needs to restore it to default state:

This command will launch the SetupWizardTestActivity, placing your device in factory mode. It's important to note that a simple reboot or uninstallation of the setup wizard won't resolve the issue. We need to take further steps to restore your device to its default state.

Getting Your Device Back to Default State

To restore your Android device from factory mode, follow these steps:

  1. Open the ADB Shell and execute the following commands:
adb shell su -c settings put system custom_wallpaper_color_areas_lock 0:0:32-0.2795139:0.2:0.7204861:0.3125
adb shell su -c settings put system screen_brightness 41
adb shell su -c settings put system screen_off_timeout 30000
adb shell su -c settings put secure user_setup_complete 1
adb shell su -c settings put secure user_setup_personalization_state 1
adb shell su -c settings put secure mcf_continuity_nearby_device_state 0
adb shell su -c settings put system device_provisioned 1

These commands will modify specific settings in the Android system to restore your device to its default state. We are setting values for custom wallpaper color areas, screen brightness, screen off timeout, user setup completion, user setup personalization state, nearby device state, and device provisioning.

  1. After executing these commands, your device will be restored to its default state. You can now use it without any problems.

Verifying Default Settings

If you're interested in checking the default settings of your device or comparing the changes caused by factory mode, you can run the following commands:

adb shell content query --uri content://settings/system > system-content.log
adb shell content query --uri content://settings/secure > secure-content.log
adb shell content query --uri content://settings/global > global-content.log

By comparing the content of these log files with the ones generated before launching the SetupWizardTestActivity, you can identify the exact changes made during factory mode.

Checking Command Output Differences

To compare the differences in settings between factory mode and non-factory mode, you can use the following commands:

adb shell settings list global > settings-global.txt
adb shell settings list secure > settings-secure.txt
adb shell settings list system > settings-system.txt
adb shell settings list global > setupwizard-settings-global.txt
adb shell settings list secure > setupwizard-settings-secure.txt
adb shell settings list system > setupwizard-settings-system.txt
adb shell settings list secure > settings-secure.txt
adb shell settings list system > settings-system.txt
adb shell settings list system > setupwizard-settings-system.txt

To view the differences, execute the following commands:

diff -y -W250 settings-secure.txt settings-secure.txt
diff -y -W250 settings-global.txt settings-global.txt
diff -y -W250 settings-system.txt setupwizard-settings-system.txt

To view the differences at same time, execute the following commands in parallel:

echo -e "global\nsettings\nsecure\n"|parallel -j3  diff -y -W250 setupwizard-settings-{}.txt settings-{}.txt|grep '|'

Global Differences

When in SetupWizard:

  • device_provisioned=0

When not in SetupWizard:

  • device_provisioned=1

System Differences

When in SetupWizard:

  • user_setup_complete=1
  • user_setup_personalization_state=1
  • mcf_continuity_nearby_device_state=0

When not in SetupWizard:

  • user_setup_complete=0
  • user_setup_personalization_state=0
  • mcf_continuity_nearby_device_state=1

Secure Differences

When in SetupWizard:

  • screen_brightness=50
  • screen_off_timeout=30000

When not in SetupWizard:

  • screen_brightness=40
  • screen_off_timeout=121000

Tip

This does not work on all devices

Another option is to terminate the SetupWizard process. However, instead of using com.sec.android.setupwizard, you should use com.sec.android.app.SecSetupWizard. This tutorial aims to help you understand the actions taking place on the device during the setup wizard phase. Additionally, please note that logcat will not display any logs beyond touchscreen inputs. We will address how to resolve this issue later on.

adb shell su -c kill -SKIGCILL $(pidof com.sec.android.app.SecSetupWizard)

Conclusion

Getting stuck in factory mode can be frustrating, but with the knowledge and steps outlined in this guide, you can easily restore your Android device to its default state. By using ADB commands and manipulating system settings, you'll be able to bring your device back to normal and regain full functionality.

Remember to exercise caution when using ADB commands and ensure that you have a backup of important data before proceeding. By following this guide, you can confidently resolve the factory mode issue and continue using your Android device without any hindrance.

So, without further ado, let's start the process of restoring your Android device from factory mode and reclaiming its normal operation!