ADB

adb shell 运行lua文件

1, android设备root权限
2, 将liblasa.so push到/system/lib下
3, 将lasa push 到/system/bin/下 , chmod 777 lasa
4, 将需要测试的lua脚本和资源等相关so puah到/data/test/目录下
5, 调用lasa test.lub
6, 测试相关打印在logcat -s lasa 输出

查询ip

adb shell ip addr
adb shell netcfg

录屏

adb shell screenrecord /sdcard/test.mp4

  1. 视频保存目录可以自己指定,如上面的/sdcard/test.mp4,命令执行后会一直录制180s,按下ctrl+c可以提前结束录制输入 –time-limit N,限制视频录制时间为N秒
  2. 对于高分辨率的手机,录制的视频很大
    adb shell screenrecord --size 848*480 /sdcard/test.mp4
  3. 默认比特率是4M/s,为了分享方便,我们可以调低比特率为2M
    adb shell screenrecord --bit-rate 2000000 /sdcard/test.mp4
  4. 使用adb pull 即可把手机SD卡中视频获取到本地
    adb pull /sdcard/test.mp4 .

日志过滤

反向过滤 : adb shell "logcat -v threadtime | grep -vE "lasa || Mtk""
正向过滤 :adb logcat lasa:D HomeNode:I *:S
只打印错误 : adb logcat *:E

选项解析 :
-- "-s"选项 : 设置输出日志的标签, 只显示该标签的日志;
-- "-f"选项 : 将日志输出到文件, 默认输出到标准输出流中, -f 参数执行不成功;
-- "-r"选项 : 按照每千字节输出日志, 需要 -f 参数, 不过这个命令没有执行成功;
-- "-n"选项 : 设置日志输出的最大数目, 需要 -r 参数, 这个执行 感觉 跟 adb logcat 效果一样;
-- "-v"选项 : 设置日志的输出格式, 注意只能设置一项;
-- "-c"选项 : 清空所有的日志缓存信息;
-- "-d"选项 : 将缓存的日志输出到屏幕上, 并且不会阻塞;
-- "-t"选项 : 输出最近的几行日志, 输出完退出, 不阻塞;
-- "-g"选项 : 查看日志缓冲区信息;
-- "-b"选项 : 加载一个日志缓冲区, 默认是 main, 下面详解;
-- "-B"选项 : 以二进制形式输出日志;

查看机器信息

adb shell getprop | grep -E "model|version.sdk|manufacture|hardware|platform|revision|serialno|product.name|brand"
附加:
grep 同时满足多个关键字和满足任意关键字
① grep -E "word1|word2|word3" file.txt
满足任意条件(word1、word2和word3之一)将匹配。
② grep word1 file.txt | grep word2 |grep word3
必须同时满足三个条件(word1、word2和word3)才匹配

adb起不来

netstat -ano >./Desktop/t.txt 找到哪个占用了5037
TCP    127.0.0.1:5037         0.0.0.0:0              LISTENING       4680
taskkill /F /pid 4680         
再尝试adb shell.

adb 查看常用属性

adb shell getprop | findstr "gsm" : 显示包含gsm的系统属性
adb shell cat /proc/meminfo : 查看当前内存情况
adb shell cat /proc/cpuinfo : cpu情况
adb shell cat /proc/iomem : io内存分区

截图

adb shell screencap -p /sdcard/1.png
adb pull /sdcard/1.png

广播

am broadcast -a 广播action : 发送一条广播
adb shell am broadcast 后面的参数有:
[-a ]
[-d ]
[-t ]
[-c [-c ] ...]
[-e|--es ...]
[--ez ...]
[-e|--ei ...]
[-n ]
[-f ] []

例如: aiosTTS播报测试
adb shell am broadcast -a aios.intent.action.SPEAK --es aios.intent.extra.TEXT 地图缩小 --ei aios.intent.extra.PRIORITY 1

pm am

am startservice -a 服务action : 启动一项服务
am force-stop 包名 : 强制关闭一个应用

package manager 简称 pm
pm install apk路径 : 安装程序
pm uninstall 包名 : 卸载程序
pm disable 包名 : 禁用应用
pm enable 包名 : 启用
pm -p 包名 : 应用装在哪里
pm list permissions
查看6.0需要动态申请危险权限
pm list permissions -d -g

input keyevent

input keyevent num : num=3:home键 num=4:back键
input text "str" : 文本输入 str
参考

dump系统信息

dumpsys activity|grep mFocusedActivity 哪个activity在最前面

top -m 10 -s cpu -d 取前十条,已cpu的暂用降序排列.-d刷新周期(秒)
svc wifi enable / svc wifi disable : 开关wifi
service list : services信息
dumpsys meminfo : 内存使用情况
dumpsys package : 安装包信息
df : 设备文件信息
mount -o remount rw /system : 把system目录挂载为可读写(mouont -rw -o remount /system)

procrank | grep com.aispeech.aios 查看aios内存占用情况
dumpsys meminfo com.aispeech.aios 查看aios内存占用情况
dumpsys cpuinfo 查看cpu占用情况
top -m 10 -s cpu 查cpu占用前10情况
busybox top 实时查看CPU占用情况
cat /proc/cpuinfo 查看硬件cpu参数

dumpsys :

dumpsys [options]
meminfo 显示内存信息
cpuinfo 显示CPU信息
account 显示accounts信息
activity 显示所有的activities的信息
window 显示键盘,窗口和它们的关系
wifi 显示wifi信息

mac地址
file = fopen("/sys/class/net/wlan0/address", "rb");
file = fopen("/sys/class/net/usb0/address", "rb");

时区
adb shell
cat /data/property/persist.sys.timezone //时区配置文件
setprop persist.sys.timezone GMT //修改属性

wifi连接adb调试

  1. 手机需要安装终端(如 : BetterTerminal)
  2. 运行: su
    setprop service.adb.tcp.port 5555
    stop adbd
    start adbd
  3. 查看手机ip 192.168.0.50 (哈哈 ,我的 , 同志们别乱连)
  4. adb connect 192.168.0.50 : 5555
    显示connected to 192.168.0.50:5555表示连接成功

谁占用了mic

adb shell dumpsys media.audio_flinger

Tracks of which 1 are active
Active Client Fmt Chn mask Session S Server fCount SRate
yes 2745 1 0000000C 24 6 0742E2AA 8000 16000
0 Effect Chains

Reroute submix audio module:
route[0] rate in=0 out=0, addr=[]
route[1] rate in=0 out=0, addr=[]
route[2] rate in=0 out=0, addr=[]
route[3] rate in=0 out=0, addr=[]
route[4] rate in=0 out=0, addr=[]
route[5] rate in=0 out=0, addr=[]
route[6] rate in=0 out=0, addr=[]
route[7] rate in=0 out=0, addr=[]
route[8] rate in=0 out=0, addr=[]
route[9] rate in=48000 out=48000, addr=[]
root@rmt8735_6tb_s_l1:/ # ps |grep aios
u0_a47 2672 279 996904 30416 ffffffff f710c988 S com.aispeech.aios.wechat
u0_a47 2745 279 1136052 98968 ffffffff f710c988 S com.aispeech.aios
system 2831 278 1344608 47140 ffffffff a3cd444c S com.aispeech.aios.adapter

高通cpu测试

#! /bin/bash
timestamp=`date +20%y%m%d%H%M%S`
while true
    do sleep 1
    adb shell cat /sys/devices/system/cpu/online >> ./cpuinfo.txt
    adb shell "top -n 1 | grep -e \"com.aispeech.aios\"" >> ./cpuinfo.txt
done

签名文件对比

可以比对apk签名的fingerprint
假定安装了JDK,如果想查HelloWorld.apk所使用的签名的fingerprint,可以这样做:

  1. 查找apk里的rsa文件

(Windows)

jar tf HelloWorld.apk |findstr RSA

(Linux)
$ jar tf HelloWorld.apk |grep RSA

META-INF/CERT.RSA

  1. 从apk中解压rsa文件

jar xf HelloWorld.apk META-INF/CERT.RSA

  1. 获取签名的fingerprints

keytool -printcert -file META-INF/CERT.RSA

...
Certificate fingerprints:
MD5: BC:6D:BD:6E:49:69:2A:57:A8:B8:28:89:04:3B:93:A8
SHA1: 0D:DF:76:F4:85:96:DF:17:C2:68:1D:3D:FF:9B:0F:D2:A1:CF:14:60
Signature algorithm name: SHA1withRSA
Version: 3
...

  1. 清理工作,删除rsa文件

(Windows)
rmdir /S /Q META-INF

(Linux)
rm -rf META-INF

debug.keystore系统签名

创建key,需要用到keytool.exe (位于jdk1.6.0_24\jre\bin目录下),使用产生的key对apk签名用到的是jarsigner.exe (位于jdk1.6.0_24\bin目录下),把上两个软件所在的目录添加到环境变量path后,打开cmd输入

D:>keytool -genkey -alias demo.keystore -keyalg RSA -validity 40000 -keystore demo.keystore
/说明:-genkey 产生密钥
-alias demo.keystore 别名 demo.keystore
-keyalg RSA 使用RSA算法对签名加密
-validity 40000 有效期限4000天
-keystore demo.keystore /
D:>jarsigner -verbose -keystore demo.keystore -signedjar demo_signed.apk demo.apk androiddebugkeystore
/
说明:-verbose 输出签名的详细信息
-keystore demo.keystore 密钥库位置
-signedjar demor_signed.apk demo.apk demo.keystore 正式签名,三个参数中依次为签名后产生的文件demo_signed,要签名的文件demo.apk和密钥库androiddebugkeystore
/

参考

杂七杂八

  1. mtk驱动层录音

com.mediatek.engineermode/.audio.AudioAudioLogger或者电话键盘##3646633##
勾选input
adb root
kill mediaserver
adb pull /sdcard/mtklog/audio_dump/


aapt常用总结

aapt d[ump] [--values] WHAT file.{apk} [asset [asset ...]]
badging Print the label and icon for the app declared in APK.
permissions Print the permissions from the APK.
resources Print the resource table from the APK.
configurations Print the configurations in the APK.
xmltree Print the compiled xmls in the given assets.
xmlstrings Print the strings of the given compiled xml assets.

来源

你可能感兴趣的:(ADB)