Android Device Connectivity Control via ADB

August 30, 2018 Android

It might be necessary to control Android device connectivity state. For example, to turn the network off while running integration tests. Often there is no way to do that programmatically. Fortunately, Android Debug Bridge has some useful shell commands.


The svc command allows to control the following types of connections:

  • WiFi
  • Mobile data
  • Bluetooth
  • NFC
  • USB

Should be run inside the interactive shell. Execute adb shell first, or prefix each command with adb shell.


Enable WiFi
svc wifi enable

Disable WiFi
svc wifi disable

Mobile data

Enable mobile data
svc data enable

Disable mobile data
svc data disable


Enable Bluetooth
svc bluetooth enable

Disable Bluetooth
svc bluetooth disable


Enable NFC
svc nfc enable

Disable NFC
svc nfc disable


Set the ‘keep awake while plugged in’ setting.
svc power stayon [true|false|usb|ac|wireless]

Perform a runtime shutdown and reboot device with specified reason.
svc power reboot [reason]

Perform a runtime shutdown and power off the device.
svc power shutdown


Set the current usb function. If function is blank, sets to charging.
svc usb setFunctions [function]

Sets the functions which, if the device was charging, become current on screen unlock. If function is blank, turn off this feature.
svc usb setScreenUnlockedFunctions [function]

Gets the list of currently enabled functions
svc usb getFunctions

Possible values of [function] are any of ‘mtp’, ‘ptp’, ‘rndis’, ‘midi’


Commands and their descriptions were taken from The Android Open Source Project source code. They are licensed under the terms of Apache License, Version 2.0.

comments powered by Disqus