9

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?

4
  • 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.
    – AtomicDog
    Commented Feb 17, 2016 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.
    – AtomicDog
    Commented Feb 17, 2016 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.
    Commented Feb 18, 2016 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
    Commented Feb 19, 2016 at 3:01

6 Answers 6

6

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.

4
  • Setup wizard isn't showing up for me after reboot. Commented May 21, 2022 at 10:11
  • Which Android device and Android version are you using?
    – Firelord
    Commented May 22, 2022 at 6:20
  • it's SM-P610 on Android 12. Commented May 22, 2022 at 7:32
  • Hmm. It is best if you ask this as a question. Please do mention there the Android device and Android version.
    – Firelord
    Commented May 22, 2022 at 13:40
6

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

4
  • How does this information relate to the question? Could you explain a little further?
    – Dan Hulme
    Commented Aug 17, 2017 at 10:48
  • Ty, this worked for me, all other options did not work because of permissions issues
    – This_is_me
    Commented Aug 26, 2017 at 0:49
  • 1
    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. Commented Sep 19, 2017 at 21:12
  • That's a useful hint. It has helped me. Thanks! It should go as an improvement or comment to Christopher's answer. It's not an answer itself. Commented Jul 31, 2019 at 21:21
4

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
4

The following command worked for me without root access:

adb shell am start -a android.intent.action.MAIN -n com.google.android.setupwizard/.deferred.DeferredSetupWizardActivity
2
  • Thanks a lot! Worked on OnePlus 6T Commented Apr 6, 2020 at 0:13
  • Worked on my Pixel 6 Pro!
    – ggonsalv
    Commented Apr 25, 2023 at 4:29
2

Had the same issue with my new Pixel 2 XL. I'd used Nova Launcher to make a widget "activities" for launching system apps previously and sure enough, Pixel Setup was in the list so I added that widget/button and it fired up and offered me to restore from a cloud backup etc.

0

If you got root you can do something like this:

#!/bin/bash

adb root
wait ${!}
adb shell pm enable com.google.android.setupwizard || true
wait ${!}
adb shell pm disable com.android.provision || true
wait ${!}
adb shell am start com.google.android.setupwizard/com.google.android.setupwizard.SetupWizardTestActivity

You can find LineageOS sample script there

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .