(1) adb 常用基本命令
adb devices 显示adb上连接的设备
adb devices -l 会显示所连接设备更多的信息
启动和关闭adb服务:(在拔掉tablet和pc的连接时,adb devices依旧没有更新的情况下,关闭再启动adb)
adb kill-server
adb start-server
adb connect ip地址 连接到某个地址的设备 如:adb connect 192.168.42.1 连接到ip为192.168.42.1的tablet, 而这个地址是由image的编码决定的,无法直接修改.
当连接more than one devices and emulator时 adb + 操作 需要指定某一设备 ,即 adb -s 设备名称 操作命令
如
List of devices attached
192.168.42.1:5555 device
emulator-5554 device
在这种情况下,如果想要重启 192.168.42.1:5555 , 可以 adb -s 192.168.42.1:5555 reboot
src/build/android/test_runner.py 该脚本可以指定运行的设备 -d 设备名称
adb shell 进入设备系统,可以查看文件内容
exit 退出adb shell
(2) tomstones可以看出错日志. 貌似是运行时crash掉的case的运行log
进入adb shell 后, /data/tombstones下可以看到adb device 运行出错日志
root@baytrail:/data/tombstones # ls
tombstone_00
tombstone_01
tombstone_02
tombstone_03
tombstone_04
tombstone_05
tombstone_06
tombstone_07
tombstone_08
tombstone_09
查看某个日志的具体内容:
root@baytrail:/data/tombstones # cat tombstone_09 |more
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'unknown'
Revision: '0'
pid: 21769, tid: 21804, name: Thread-52161 >>> org.chromium.content_browsertests_apk <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000001
eax 00000001 ebx e6226ff4 ecx e6226ff4 edx f99700d0
esi e5117d88 edi e1e79888
xcs 00000023 xds 0000002b xes 0000002b xfs 00000087 xss 0000002b
eip e5117da1 ebp e1e79828 esp e1e797e0 flags 00210292
backtrace:
#00 pc 02115da1 /data/app-lib/org.chromium.content_browsertests_apk-1/libcontent_browsertests.so
#01 pc 02117f8f /data/app-lib/org.chromium.content_browsertests_apk-1/libcontent_browsertests.so
#02 pc 021180ad /data/app-lib/org.chromium.content_browsertests_apk-1/libcontent_browsertests.so
#03 pc 0059d0ae /data/app-lib/org.chromium.content_browsertests_apk-1/libcontent_browsertests.so
#04 pc 0059cfd5 /data/app-lib/org.chromium.content_browsertests_apk-1/libcontent_browsertests.so
--more--
如上,显示出错文件在libcontent_browsertests.so,于是可以用locate查找文件位置
然后用一个貌似叫addr2line的东西,可以根据内存地址(上面红色标注的),找到对于出错的code
(3) abd shell + command 和在linux terminal中, 先输入 adb shell 进入 android 系统,然后再输入 command的效果是一样的.
此外,部分命令, 在linux 下 adb+ command的命令和在adb shell中输入command的效果是一样的
如: adb reboot
adb logcat (和在adb shell 中输入logcat效果相同)
(4)svc命令,在adb shell 中可以直接使用,位于/system/bin下, 功能:电源管理,wifi管理,黑屏亮屏管理等如点亮屏幕(相当于人工按亮屏键,屏幕由黑屏到亮), svc power stayon usb