setNetwork

suspend fun setNetwork(airplaneMode: Boolean? = null, wifi: Boolean? = null, mobileData: Boolean? = null)(source)

Switches airplane mode, Wi-Fi and mobile data on or off until detach, see setAnimations; a null switch is left as it is. These are the device's real switches (nothing is mocked): the app sees what it would see if a user flipped them, and turning Wi-Fi on says nothing about when it connects. Airplane mode is applied first, so setNetwork(airplaneMode = true, wifi = true) is airplane mode with Wi-Fi on. API 29+. A device reached over ADB on the network refuses Wi-Fi off or airplane mode on (FailureReason.DEVICE_SETTING): that would cut Tap off. Read back with DeviceInfo.airplaneMode, DeviceInfo.wifiEnabled and DeviceInfo.mobileDataEnabled.