Block reference / Device Management

Toggle service

Switch Wi-Fi, mobile data, Bluetooth, airplane mode or location on or off.

Only inWarpX Phone

Toggle service switches one of the phone's radios: Wi-Fi, mobile data, Bluetooth, airplane mode or location. It can switch it to on or off, or the other way from how it is now. After switching, the block reads the setting back and fails if the phone did not let it change, rather than carrying on as if it had.

Toggle service switches airplane mode on, then reads it back to be sure the phone took it.
The Toggle service block's settings, filled in as in the example below.

Settings

Service

Wi-Fi, Mobile data, Bluetooth, Airplane mode or Location (GPS).

ExampleAirplane mode
Switch / Toggle

The two choices under Service. Switch sets it to the state below. Toggle turns it off when it is on and on when it is off.

ExampleSwitch
Switch itwhen Switch / Toggle is Switch

On or Off.

ExampleOn
Delay (ms)

A wait after the block finishes, before the next one starts. One number such as 1000, or a range such as 1000,3000 for a random wait in that range on each run.

Example0

Every block also has the shared block settings — a description, Disable block and what to do on an error. Fields that take text accept data from earlier blocks.

What it hands on

Hands on whether the service is on afterwards, true or false, as {{prevBlockData}}. Writes no variable.

Example: Get a new mobile IP with airplane mode

  1. Start
  2. Toggle service
  3. Delay
  4. Toggle service
  5. Check network
Where Toggle service sits in the example workflow.
  1. Pick a phone on mobile data, connected to this computer by USB.
  2. Add a Toggle service block: Service Airplane mode, Switch, Switch it On.
  3. Add a Delay block of 5000 milliseconds.
  4. Add a second Toggle service block for Airplane mode set to Off.
  5. Add a Check network block with Save the public IP to a variable set to publicIp, and click Run.

Good to know

  • It works without root on Android 11 and later. On some older phones mobile data or airplane mode needs root, and the block fails with SERVICE_FAILED saying the setting did not change.
  • A phone connected over Wi-Fi refuses Wi-Fi off and Airplane mode on, since either would cut WarpX Phone off from it. Use a USB connection for those.
  • Toggle fails when the phone does not say whether the service is on; use Switch then.

See also

  • Check network — Check whether the phone reaches the internet, and read the public IP sites see it at.
  • Screen action — Turn the phone's screen on or off, dismiss a swipe lock, or turn the screen.
  • Phone identity — Put the phone on a proxy, and set its location, time zone and language, all at once.
  • ADB command — Run a command in the phone's shell, as adb shell does, and keep what it prints.