adb devices
adb wait-for-device
-s加序列号 来指定要操作的设备建议每次只连接一个安卓设备进行操作!!!
建议每次只连接一个安卓设备进行操作!!!
建议每次只连接一个安卓设备进行操作!!!
$ adb devices
List of devices attached
FA6AX0301341 device
ce0217122b56b02604 device
$ adb -s FA6AX0301341 shell
sailfish:/ $
adb shell input keyevent 26 //锁定手机 adb shell input keyevent 82 //解锁手机(如果设置了密码,会提示输入密码)
adb shell input text 123456 && adb shell input keyevent 66
adb reboot //重启 adb shell reboot //重启 adb shell reboot -p //关机
adb shell service call bluetooth_manager 6 //打开蓝牙 adb shell service call bluetooth_manager 9 //关闭蓝牙
adb shell svc wifi enable //打开wifi adb shell svc wifi disable //关闭wifi
adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
svc power stayon [true|false|usb|ac|wireless]
参数解释:
true: 任何情况下均保持亮屏
false:任何情况下均不保持亮屏(经过设定的时间后自动黑屏)
usb, ac, wireless:设置其中之一时,仅在这一种情况下才保持亮屏。
adb shell input keyevent 111 //关闭软键盘(其实是按下ESC,111=KEYCODE_ESCAPE)
更多按键代码,在这里
https://developer.android.com/reference/android/view/KeyEvent.html
adb shell input touchscreen swipe 930 880 930 380 //向上滑 adb shell input touchscreen swipe 930 880 330 880 //向左滑 adb shell input touchscreen swipe 330 880 930 880 //向右滑 adb shell input touchscreen swipe 930 380 930 880 //向下滑
adb shell input mouse tap 100 500
100是x,500是y。
原点在屏幕左上角。
adb shell am start -a android.intent.action.CALL -d tel:10010
adb shell am start -a android.intent.action.VIEW -d http://google.com
adb shell am start -n com.package.name/com.package.name.MainActivity
adb shell am start -n com.package.name/.MainActivity
$ adb shell monkey -p com.android.contacts -c android.intent.category.LAUNCHER 1 Events injected: 1 ## Network stats: elapsed time=16ms (0ms mobile, 0ms wifi, 16ms not connected)
adb get-serialno
$ adb shell ls sys/class/thermal/ cooling_device0 cooling_device1 cooling_device2 cooling_device3 cooling_device4 cooling_device5 thermal_zone0 thermal_zone1 thermal_zone2 thermal_zone3 thermal_zone4 thermal_zone5 thermal_zone6 thermal_zone7
查看某个CPU温度
$ cat /sys/class/thermal/thermal_zone0/temp 25800
温度是milliCelsius,所以这里是25.8度C。
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors userspace interactive performance
参考:https://forum.xda-developers.com/showthread.php?t=1663809
设置CPU governor为performance。
echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
adb reboot recovery //恢复模式 adb reboot bootloader //刷机模式。不同手机,命令不同,要试一下。 adb reboot-bootloader adb reboot boot loader
adb reboot fastboot
或
关机,然后同时按住 增加音量 和 电源 键开机
adb wait-for-device && adb shell logcat -v threadtime | tee mybootup.log
adb logcat
adb kill-server adb start-server
adb push test.zip /sdcard/ //从本地复制文件到设备 adb pull /sdcard/abc.zip ~/ //从设备复制文件到本地
adb shell pm list packages
adb install abc.apk //第一次安装。如果手机上已经有此app,则会报错。 adb install -r abc.apk //如果已经安装过,保留原app的数据 adb -s 11223344 install abc.apk //当多个安卓连接到电脑时,安装到指定一台安卓上 adb uninstall com.example.appname
aapt dump badging abcd.apk |grep version
adb shell getevent -ltr
wm density
wm size
设置:
wm density 240
立刻生效。