In part of my testing I’m checking if my app can handle returning from airplane mode to normal mode.
Looking for a process that enable/disable airplane mode on real Android device.
All I found is how to enable/disable WiFi and data on simulator here - Best way to turn airplane mode on and off with Calabash.
Tried to run those commands on my real device (LG G3 – Android 5.0) and nothing happened.
Looking on my services list on my device (
adb shell service list) but cannot find airplane.
I understand that changing to airplane mode is disabling the data/WiFi/Bluetooth/GPS
Is there a way to enable airplane mode on real device?
Or even just the data/WiFi (enough for my testing)?
If you have no luck with adb commands,
You can enable/disable airplane mode with
adb shell input gestures.
adb -s <DeviceSerialNumber> shell input touchscreen swipe x1 y1 x2 y2 time
x1,x2,y1,x2 is swipe start and end coordinates and
time is time in ms to perform the gesture.
By combining these, you can perform anything on screen.
For example airplane mode.
Not the best way to do that, but comes handy sometimes.
Another way around that
Check the settings you interested in, and use
adb shell settings put
adb -s <DeviceSerialNumber> shell settings put global airplane_mode_on 1
A question about events:
How to use ADB to send touch events to device using sendevent command?