Set network settings command

Sets the status of the specified network settings: wifi, data (only for devices with a valid SIM card installed), and/or airplane-mode.

Restriction: Setting airplane mode is supported for devices running Android version 7.0 or earlier. Setting the radio mode works for devices running Android version 9.0 or earlier but is subject to Google not changing the implementation, so the command is not guaranteed to work in the future.

If the device does not reconnect when the radio signal is turned on, you may need to do one of the following:

  • Reboot the device
  • Turn airplane mode off and immediately back on

Parameters

Name

Type

Possible values

Description

Device ID*

Device

 

The device for this command. By default, this is the device under test (DUT).

WiFi

String

Enabled | Disabled

Enable/disable the device WiFi.

Data

String

Enabled | Disabled

Enable/disable the device data from the mobile carrier. The device must have a SIM.

Available for Android version 2.3 to 4.4.

Airplane mode

String

Enabled | Disabled

Enable/disable the device Airplane mode.

Tip: If this parameter does not work on the Android version you are working with, try using the command parameter of the mobile:handset:shell command instead, as follows:
Copy
Map<String, Object> params1 = new HashMap<>();
params1.put("command", "cmd connectivity airplane-mode enable");
driver.executeScript("mobile:handset:shell", params1);

This solution seems to work for Android versions 10 and later.

Radio mode

String

Enabled | Disabled

Enable/disable the device radio signal.

Comment

String

 

Adds a comment to the script.

On-fail Result*

Condition

Ignore | Break | Continue | Abort | Catch

The behavior when the command fails.

* Mandatory parameter