当前位置: 动力学知识库 > 问答 > 编程问答 >

wifi - Airplane mode simulation on a real Android device with calabash-android

问题描述:

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

Where 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.

  • Get screen resolution of your device
  • Swipe notification bar from the top
  • Touch airplane mode
  • And press back button

Not the best way to do that, but comes handy sometimes.

Another way around that

https://developer.android.com/reference/android/provider/Settings.Global.html

Check the settings you interested in, and use adb shell settings put

For example:

  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?

分享给朋友:
您可能感兴趣的文章:
随机阅读: