adb命令

总结了写adb命令

查看手机应用名 adb shell pm list packages 查看对应apk安装位置 adb shell pm list packages -f

日历 :com.asus.smartcalendar 类名:com.asus.smartcalendar.HomeActivity 百度浏览器:com.baidu.browser.apps_mr 类名: com.baidu.browser.apps.BrowserActivity 高德地图:com.autonavi.minimap 类名:com.autonavi.map.activity.SplashActivity 录音机:com.asus.soundrecorder 类名:com.asus.soundrecorder.AsusRecorder

MTK adb 进入工程模式 : adb shell am start -n com.mediatek.engineermode/.EngineerMode

打开亮度自动调整:adb shell settings put system screen_brightness_mode 1 关闭亮度自动调整:adb shell settings put system screen_brightness_mode 0

注意:关闭亮度自动调节之后才能设置亮度值

设置亮度值: adb shell settings put system screen_brightness 100(亮度值:0-255) 获取当前亮度值:adb shell settings get system screen_brightness

打开飞行模式: (1) adb shell settings put global airplane_mode_on 1(不推荐,不能完全消除信号,可以接听,不能拨打)

(2) adb shell am broadcast -a android.intent.action.AIRPLANE_MODE –ez state true (不推荐,手机需要root)

(3) AT+CFUN = 1 (AT 命令)

关闭飞行模式: (1)adb shell settings put global airplane_mode_on 0

(2)adb shell am broadcast -a android.intent.action.AIRPLANE_MODE –ez state false

(3) AT+CFUN = 0

更改休眠时间,10分钟: adb shell settings put system screen_off_timeout 600000 (单位:ms)

获取屏幕休眠时间: adb shell settings get system screen_off_timeout

保持屏幕常亮:adb shell svc power stayon true

关闭屏幕常亮:adb shell svc power stayon false

sdk >=23 6.0 系统操作gps提供者需要’+’,’-‘

打开GPS:adb shell settings put secure location_providers_allowed +gps/+network

关闭GPS:adb shell settings put secure location_providers_allowed -gps/-network

am start -n com.asus.smartcalendar/com.asus.smartcalendar.HomeActivity am start -n com.baidu.browser.apps_mr/com.baidu.browser.apps.BrowserActivity am start -n com.autonavi.minimap/com.autonavi.map.activity.SplashActivity am start com.android.settings/com.android.settings.Settings am start -n com.asus.soundrecorder/com.asus.soundrecorder.AsusRecorder

AT+CGDATA=”M-0000”,1 //挂断网络

注网状态:AT+CREG=2 =>AT+CREG? 返回+CREG: 2,1(成功)/0(失败),”1877”,”0878C535”,7

设置耳机音量:AT+CLVL=3

设置麦克风音量:AT+CMUT=0;

数据业务呼叫:ATD#777

android.intent.action.DREAMING_STARTED系统开始休眠

android.intent.action.HEADSET_PLUG插入耳机

系统休眠:adb shell input keyevent 223

退回主界面:adb shell input keyevent 3

POWER键关屏再开屏:adb shell input keyevent 26

重启手机:adb reboot

手机关机:adb shell reboot -p

恢复出厂设置(用户级)adb reboot resetuser

通过设置界面打开WiFi: adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings

adb shell input keyevent 20 & adb shell input keyevent 23

开启数据开关:adb shell svc data enable

判断是否锁屏: adb shell

dumpsys window policy grep isStatusBarKeyguard
dumpsys window policy grep mShowingLockscreen

保持屏幕常亮:adb shell svc power stayon true

屏幕亮度:亮度值为0-255,adb shell settings put system screen_brightness 128

熄灭屏幕:adb shell input keyevent 223(不是感应灭屏)

打开高德地图:adb shell am start -n com. autonavi. Minimap /com.autonavi.map.activity.SplashActivity

检查手机是否注册上现网:AT+CREG?

打开浏览器:adb shell am start -n com.baidu.browser.apps_mr/com.baidu.browser.apps.BrowserActivity

输入网址:am start -a android.intent.action.VIEW -d http://www.china.com

恢复/暂停播放:adb shell input keyevent 126/127

adb shell dumpsys audio adb shell service audio 9 i32 50

使用Google的办法: https://www.google.com/ncr

设置媒体音量:adb shell service call audio 3 i32 3 i32 0(0-15) i32 1

设置蓝牙音量:adb shell service call audio 3 i32 6 i32 0(0-15) i32 1

设置闹钟音量:adb shell service call audio 3 i32 4 i32 0(0-15) i32 1

查看耳机是否插入: 1.adb shell

2.dumpsys activity broadcasts|grep microphone |tail -n 1 state=1 有耳机 state=0 没有耳机

设置网络首选模式:

adb shell settings list global grep pref

adb shell settings put global preferred_network_mode 1

adb shell settings put global preferred_network_mode1 1

adb shell settings put global preferred_network_mode2 1

adb shell settings put global preferred_network_mode3 1 reboot (1 GSM only 11 LTEonly 具体参照网络首选模式编号.txt)

蓝牙

没有root的设备 通过设置打开蓝牙: adb shell am start -a android.intent.action.MAIN -n com.android.settings/.bluetooth.BluetoothSettings adb shell input keyevent 20 & adb shell input keyevent 23

有root的设备

1.adb shell service call bluetooth 3打开蓝牙/adb shell service call bluetooth 4关闭蓝牙

2.adb shell -c service call bluetooth_manager 6打开蓝牙/adb shell -c service call bluetooth_manager 8关闭蓝牙

3.adb shell am start -a android.bluetooth.adapter.action.REQUEST_ENABLE(需要另外点OK) am start -a android.bluetooth.adapter.action.REQUEST_ENABLE &input keyevent 20 & adb shell input keyevent 22 & adb shell input keyevent 23

4.adb shell am start -a android.bluetooth.adapter.action.REQUEST_DISCOVERABLE 开启120秒的蓝牙可检测

5.获取设备自身的蓝牙MAC地址:settings get secure bluetooth_address

打开开发者模式:adb shell am start -n com.android.settings/.DevelopmentSettings

-s:指定产生随机事件种子值,相同的种子值产生相同的事件序列。如: -s 200

–throttle:每个事件结束后的间隔时间——降低系统的压力(如不指定,系统会尽快的发送事件序列)。如:–throttle 100

–pct-touch:指定触摸事件的百分比,如:–pct-touch 5% , 相关的还有以下option:

–pct-motion (滑动事件)、 --pct-trackball (轨迹球事件) 、 --pct-nav (导航事件 up/down/left/right)、 --pct-majornav (主要导航事件 back key 、 menu key)、 --pct-syskeys (系统按键事件 Home 、Back 、startCall 、 endCall 、 volumeControl)、 --pct-appswitch (activity之间的切换)、 --pct-anyevent(任意事件) -dbg-no-events:初始化启动的activity,但是不产生任何事件。

–hprof:指定该项后在事件序列发送前后会立即生成分析报告 —— 一般建议指定该项。

–ignore-crashes:忽略崩溃

–ignore-timeouts:忽略超时

–ignore-security-exceptions:忽略安全异常

–kill-process-after-error:发生错误后直接杀掉进程

–monitor-native-crashes:跟踪本地方法的崩溃问题

–wait-dbg:知道连接了调试器才执行monkey测试。 设置点击次数500次并生成log adb shell monkey -p com.xy.android.junit -s 500 –ignore-crashes –ignore-timeouts –monitor-native-crashes -v -v 10000 > E:\monkey_log\java_monkey_log.txt

慢慢积累,慢慢整理