Block reference / Device Management
Toggle service
Switch Wi-Fi, mobile data, Bluetooth, airplane mode or location on or off.
Only in
WarpX 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.
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 as1000,3000for 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
- Start
- Toggle service
- Delay
- Toggle service
- Check network
- Pick a phone on mobile data, connected to this computer by USB.
- Add a Toggle service block: Service Airplane mode, Switch, Switch it On.
- Add a Delay block of
5000milliseconds. - Add a second Toggle service block for Airplane mode set to Off.
- 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_FAILEDsaying 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 shelldoes, and keep what it prints.