How to Turn Off WiFi via ADB

How to Turn Off WiFi via ADB

22 April 2024 Stephan Petzl Leave a comment Tech-Help

Automating testing procedures for features like WiFi calling often requires the ability to control device settings programmatically. One common task is to enable or disable WiFi on an Android device using Android Debug Bridge (ADB). This guide provides a step-by-step approach to do just that using ADB commands.

Turning WiFi On or Off for Rooted Devices

For rooted Android devices, managing WiFi can be done straightforwardly with the following ADB commands:

  • To enable WiFi:
adb shell su -c 'svc wifi enable'
  • To disable WiFi:
  • adb shell su -c 'svc wifi disable'

    Note that these commands require root access to the Android device.

    Turning WiFi On or Off for Non-Rooted Devices

    For non-rooted devices, the approach is slightly different. As of Android 11 & 12, you can use the following commands:

    • To enable WiFi:
    adb shell cmd -w wifi set-wifi-enabled enabled
  • To disable WiFi:
  • adb shell cmd -w wifi set-wifi-enabled disabled

    This method does not require root access and is suitable for recent Android versions.

    Using Key Events

    If the methods above are not suitable for your device or Android version, you can simulate key events to navigate the UI and toggle WiFi settings:

    adb shell am start -a android.intent.action.MAIN -n
    adb shell input keyevent 20 & adb shell input keyevent 23

    This sequence of commands will open the WiFi settings and simulate key presses to toggle WiFi. However, the key events may vary depending on the device and its UI, so adjustments might be necessary.

    Automating Testing with Repeato

    While ADB commands provide a manual way to toggle WiFi settings, you can streamline your testing process with Repeato, a no-code test automation tool that supports iOS and Android apps. Repeato offers a fast and efficient way to create, run, and maintain automated tests using computer vision and AI.

    With Repeato, you can automate complex testing scenarios involving network connectivity changes without the need for intricate ADB command sequences. It’s compatible with various app frameworks, including React Native, Flutter, and Unity. Moreover, Repeato comes with ADB onboard, allowing you to execute ADB commands via script steps, providing a powerful and versatile testing solution.


    Whether you’re working with rooted or non-rooted Android devices, ADB provides the means to control WiFi settings programmatically. However, for more comprehensive and automated testing, consider using tools like Repeato to enhance your testing capabilities and efficiency.

    Like this article? there’s more where that came from!