解决monkey偶尔关闭wifi和gps的问题,避免monkey自动关闭wifi

1、关闭手机状态栏,减少点击关闭WiFi的次数。

adb shell settings put global policy_control immersive.full=*

2、解决monkey偶尔跑到关闭wifi。

思路:定时检测wifi状态,如果是关闭的,就打开wifi设置页面,打开wifi按钮,然后就会自动连接了。

python代码如下:(PS:不是所有手机可用,跟安卓系统版本有一定关系,adb命令不是所有系统可用,对于安卓新版本可能有更换)

def check_wifi():
    check_wifi="adb shell dumpsys wifi |grep 'Wi-Fi is'"
    setting_command="adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings"
    open_wifi_command="adb shell input keyevent 19 & adb shell input keyevent 23"
    wifi_state = execute_shell(check_wifi) #execute_shell是另外一个写的方法,执行shell命令并返回结果
    if "disabled" in wifi_state:
        execute_shell(setting_command)
        execute_shell(open_wifi_command)
        if "disabled" in wifi_state: #双重保险
            utils_exec_shell(open_wifi_command)

3、解决gps关闭问题。

定时执行打开gps:adb shell settings put secure location_providers_allowed +gps

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值