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?

  • No root, and currently using a motorola G on 4.3. with that said, since majority of phones use SetupWizard I am looking for a mostly-universal ADB solution that can work with 6.0 as well. There has to be a flag somewhere to tweak, I just can't find it. – user2890953 Feb 17 '16 at 17:21
  • I am trying to get SetupWizard to start up at boot as if it were a freshly reset phone. that is all. – user2890953 Feb 17 '16 at 17:24
  • "I can't figure out what triggers it to start at boot" it's a combination of using RECEIVE_BOOT_COMPLETED permission and setting the global flag SETUP_WIZARD_HAS_RUN... though running adb shell settings put global setup_wizard_has_run 0 and rebooting didn't solve this... – Andrew T. Feb 18 '16 at 6:34
  • @AndrewT. setting that property doesn't work because the components of Setup Wizard are disabled once the wizard ends. I have it covered in my answer below. – Firelord Feb 19 '16 at 3:01

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 setup in PC.

Following are some screenshots serving as a proof:

(Click image to enlarge)

IMG: IMG: IMG:

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.

IMG:

Here are the instructions I followed:

  1. 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'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.

  2. 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.

  3. 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.
    
  4. 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.

In addition to Christopher's answer

settings put global device_provisioned 0

Will disable some of the functionalities of the phone and will be unlocked after setup wizard.

adb shell settings put global setup_wizard_has_run 1

adb shell settings put secure user_setup_complete 1

adb shell settings put global device_provisioned 1

Will unlock all features of the phone as far as I know, vice versa.

Just in case someone needs these information

  • How does this information relate to the question? Could you explain a little further? – Dan Hulme Aug 17 '17 at 10:48
  • Ty, this worked for me, all other options did not work because of permissions issues – This_is_me Aug 26 '17 at 0:49
  • Thanks, this helped me solve the problem where the home button doesn't work and the notification tray and quick settings are unavailable. Most solutions on the web tell you install Nova Launcher and trigger the setup wizard, which will in turn set certain settings, but that doesn't work on LineageOS. (@DanHulme that's how it relates to the original question.) This is a much easier solution, provided you have adb running. – marcvangend Sep 19 '17 at 21:12

The following shell script will trigger the Google Setup Wizard:

#!/bin/bash

adb root
adb remount

adb shell settings put global setup_wizard_has_run 0

adb shell settings put secure user_setup_complete 0

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"'

adb shell pm enable com.google.android.setupwizard/.SetupWizardActivity

adb shell am start -n com.google.android.setupwizard/.SetupWizardActivity

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.