iis服务器助手广告广告
返回顶部
首页 > 资讯 > 移动开发 >adb获取手机设备蓝牙&热点&wifi状态并操作的笔记
  • 566
分享到

adb获取手机设备蓝牙&热点&wifi状态并操作的笔记

adbandroid 2023-09-21 20:09:08 566人浏览 八月长安
摘要

adb获取手机设备蓝牙&热点&wifi状态并操作的笔记 在windows上查找字符串使用的是findstr,在linux上使用的是grep 1 #获取状态 2 3 $ adb shell ps |

adb获取手机设备蓝牙&热点&wifi状态并操作的笔记
windows上查找字符串使用的是findstr,在linux上使用的是grep

1 #获取状态 2  3 $ adb shell ps | findstr wifi 4 #output中出现wpa_supplicant说明wifi处于开启状态,如果出现hostapd说明热点处于开启状态 5 $ adb shell dumpsys wifi | findstr curState 6 #output中出现Active说明wifi处于开启状态 7  8  9 10 #操作改变状态11 方法112 $ adb shell svc wifi enable13 #enable是打开,disable是关闭 如果output是killed,说明没有root权限,adb shell之后还要加su权限14 方法215 $ adb shell am start -n com.Android.settings/.wifi.WifiSettings 或者 adb shell am start -a android.intent.action.MaiN -n com.android.settings/.wifi.WifiSettings16 $ adb shell input keyevent 2017 $ adb shell input keyevent 2318 #不一定适用所有机型,需要事先测试19 方法320 adb shell am broadcast -a io.appium.settings.wifi --es setstatus enable21 #这个是调用了appium的端口发布全局广播,打开wifi,使用后会有弹窗询问是否允许,需要点击掉弹窗

热点

1 #获取状态 2  3 在获取wifi状态中有提到 4  5  6  7 #操作改变状态 8 方法19 adb shell am start -n com.android.settings/.TetherSettings10 adb shell input keyevent 2011 adb shell input keyevent 6612 #不一定适用所有机型,需要事先测试13 方法214 #打开热点15 adb shell service call connectivity 24 i32 016 #关闭热点17 adb shell service call connectivity 25 i32 018 此操作需要root权限 ; 末尾的0是传递的参数,0是wifi网络共享,1是usb网络共享,2是蓝牙网络共享19 更多信息可参考:https://android.stackexchange.com/questions/111226/using-adb-shell-how-i-can-disable-hotspot-tethering-on-lollipop-nexus-5

蓝牙

 1 #获取状态 2 $ adb shell settings get global bluetooth_on 3 output是010代表关闭,1反之 4 $ adb shell dumpsys bluetooth_manager | grep enabled 5 output是true或者false,说明开启或关闭 6  7 #改变操作状态 8 方法19 $ adb shell settings put global bluetooth_on 110 #末尾设置为0代表关闭,1反之11 方法212 $ adb shell svc bluetooth enable13 #末尾设置为enable为开启,disable反之(这个方法输入命令后并不立即生效,重启设备才生效)14 方法315 $ adb shell am start -a android.bluetooth.adapter.action.REQUEST_ENABLE16 #目前只能从关闭状态转为开启状态,并且运行指令后会有弹窗提示是否开启蓝牙17 方法418 adb shell am start -a android.settings.BLUETOOTH_SETTINGS19 adb shell input keyevent 2020 adb shell input keyevent 2021 #同之前的启动方式,不一定适用所有机型22 方法523 adb shell am broadcast -a io.appium.settings.bluetooth --es setstatus enable24 #这个是调用了appium的端口发布全局广播,打开蓝牙,打开后会有弹窗询问允许,脚本中需要添加点击掉弹窗的方法

来源地址:https://blog.csdn.net/weixin_45393723/article/details/129964252

--结束END--

本文标题: adb获取手机设备蓝牙&热点&wifi状态并操作的笔记

本文链接: https://www.lsjlt.com/news/414581.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作