【Monkey】Android runs google Monkey, and the wifi of the mobile phone is turned off, causing the APP to run most of the time without a network, and some services cannot be tested

  1. Solution one for this problem:
adb shell "svc wifi enable"  #打开wifi
adb shell "svc wifi disable" #关闭wifi

Reference document: https://stackoverflow.com/questions/10033757/how-to-turn-off-wifi-via-adb?rq=1

  1. Solution two for this problem:

Reference document: https://www.jianshu.com/p/4e3f80adaeb1
https://www.jianshu.com/p/685037cc2883

  1. How to judge whether wifi is connected or closed by adb command
    Execute on linux or Mac
adb shell "dumpsys wifi |grep 'Wi-Fi is'"

Execute on Windows:

adb shell "dumpsys wifi |grep 'Wi-Fi is'"

Wi-Fi is disabled or Wi-Fi is enabled
Reference documentation: https://stackoverflow.com/questions/31604610/how-to-test-wifi-connection-via-adb

  1. The mobile phone does not need to be rooted, and the above commands can take effect. I have tried it on Huawei P20 (os8.1.0, os9.1.0), Xiaomi mix3 (os10), OPPO Reno Z (os10), and they all work.

Some useful ADB commands
awesome-adb/

Guess you like

Origin blog.csdn.net/weixin_45329445/article/details/112847698