Trigger Setup Wizard at next boot using command-line I am looking for a way to use ADB to trigger Setup Wizard at next boot. I know I can run the following command and get it to pop up. However, I can't figure out what triggers it to start at boot.

adb shell am start -a android.intent.action.MAIN -n com.google.android.setupwizard/.SetupWizardTestActivity


The phone I am currently using is stock and I would like to keep it that way. 

I've read the  question:
how to re-enable first time setup at next boot?
Note: This solution: 


requires a rooted Android;
is tested on Android 4.4.2, Vanir (Android 5.1.1) and on an unofficial CM13 build;
requires adb setup in PC.




Following are some screenshots serving as a proof:

(Click image to enlarge)





Note that you cannot replicate those images by issuing that shell command, because the test activity you would run would hide all the icons in the left of status bar and even time in my ROM. 



Here are the instructions I followed:


Find the disabled components. Do:


adb shell dumpsys PACKAGE  


Replace PACKAGE with package name of Setup Wizard app. Often, it would be a setup wizard from Google with package name com.google.android.setupwizard. Package name of CyanogenMod's setup wizard 
is com.cyanogenmod.setupwizard. If it has GApps installed, then use package name of Google's setup wizard. If none of the package name works then this resource may help: View app&#39;s full package name?

This step inter alia provided me a list of components of that app currently disabled. Here is a relevant excerpt under the heading Packages: from the output of the said command: 


User 0: installed=true hidden=false stopped=false notLaunched=false enabled=0
  disabledComponents:
  com.google.android.setupwizard.account.RestoreServicee
  com.google.android.setupwizard.carrier.MobileDataActivity$HfaChangeReceiver
  com.google.android.setupwizard.util.SetupWizardAdminReceiver
  com.google.android.setupwizard.SetupWizardActivity
  com.google.android.setupwizard.util.GservicesChangedReceiver
  com.google.android.setupwizard.carrier.MobileConnectivityChangeReceiver


com.google.android.setupwizard.SetupWizardActivity is the main and default activity of that app. Although the app has requested the permission android.permission.RECEIVE_BOOT_COMPLETED, strangely, there is no receiver declared in the manifest to receive android.intent.action.BOOT_COMPLETED broadcast. My guess is that the property user_setup_complete alone is used for the purpose of launching that app. 
Whatsoever the disabled components shown in your command's output for User 0 are, simply enable all of them for the same user. The simplest way is to use pm command.

adb shell
su
pm enable PACKAGE/COMPONENT


An example to enable a component:


pm enable com.google.android.setupwizard/com.google.android.setupwizard.carrier.MobileDataActivity\$HfaChangeReceiver


Note: It is not clear to me why but when I tried to enable the components using an app (say X), they were disabled automatically once I exited the X app. So I recommend you enable the components using the command-line and refrain from interacting with screen at all costs.
Get the property name:


adb shell 'content query --uri content://settings/global | grep -e "setup" -e "complete"'
adb shell 'content query --uri content://settings/secure | grep -e "setup" -e "complete"'
adb shell 'content query --uri content://settings/system | grep -e "setup" -e "complete"'


One of the commands must return output containing either the key user_setup_complete or, as Andrew T. noted, setup_wizard_has_run. 

Once you have the key, do:


adb shell settings put secure KEY 0  # replace KEY with the key noted above.
 
Do adb reboot for full reboot or adb shell su -c 'setprop ctl.restart zygote' for soft-reboot or reboot ordinarily as you would and there you would have the Setup Wizard app waiting for interaction after reboot is completed.