Android 中adb命令总结
Android 中adb命令总结
- cat 命令
直接查看文件的内容
- touch 命令
创建一个文件
- echo 命令
echo "hello world" > demo.txt //忘指定文件写数据
- adb shell dumpsys activity top
可以查看当前Activity的信息,以及布局信息
- adb shell dumpsys package
可以查看指定报名应用的信息,包括app 启动Activity 注册的服务,广播,内容提供者,以及注册的权限,版本信息,SDK 的版本信息等.
- adb shell dumpsys meminfo
可以查看指定进程或者进程id的内存信息
Applications Memory Usage (in Kilobytes):
Uptime: 746094405 Realtime: 1022778666
** MEMINFO in pid 28849 [com.sunkaisens.skdroidim] **
Pss Private Private SwapPss Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 27024 26980 4 15 31360 28162 3197
Dalvik Heap 5833 5548 244 6 10540 4396 6144
Dalvik Other 4272 4268 0 0
Stack 872 872 0 0
Ashmem 2 0 0 0
Gfx dev 18852 16704 0 0
Other dev 8 0 8 0
.so mmap 5075 432 2324 4
.apk mmap 623 0 68 0
.ttf mmap 73 0 0 0
.dex mmap 17524 15744 100 0
.oat mmap 521 0 0 0
.art mmap 3518 3280 116 0
Other mmap 620 4 4 0
GL mtrack 6664 6664 0 0
Unknown 4198 4184 4 0
TOTAL 95679 84680 2872 25 41900 32558 9341
App Summary
Pss(KB)
------
Java Heap: 8944
Native Heap: 26980
Code: 18668
Stack: 872
Graphics: 23368
Private Other: 8720
System: 8152
TOTAL: 95679 TOTAL SWAP PSS: 25
Objects
Views: 234 ViewRootImpl: 2
AppContexts: 6 Activities: 2
Assets: 13 AssetManagers: 3
Local Binders: 26 Proxy Binders: 40
Parcel memory: 16 Parcel count: 63
Death Recipients: 0 OpenSSL Sockets: 0
WebViews: 0
SQL
MEMORY_USED: 175
PAGECACHE_OVERFLOW: 29 MALLOC_SIZE: 117
DATABASES
pgsz dbsz Lookaside(b) cache Dbname
4 32 109 23/30/6 /data/user/0/com.sunkaisens.skdroidim/databases/sunkaisens.db
j3y17qltecmcc:/ $
- adb shell dumpsys dbinfo
可以查看指定应用包名的数据库信息(包括存储的sql语句)
可以看应用执行过的sql语句
j3y17qltecmcc:/ $ dumpsys dbinfo com.sunkaisens.skdroidim
Applications Database Info:
** Database info for pid 28849 [com.sunkaisens.skdroidim] **
Connection pool for /data/user/0/com.sunkaisens.skdroidim/databases/sunkaisens.db:
Open: true
Max connections: 1
Secure db: false
Available primary connection:
Connection #0:
isPrimaryConnection: true
onlyAllowReadOnlyOperations: true
Most recently executed operations:
0: [2000-01-02 01:00:52.237] [Pid:(28849)]executeForCursorWindow took 0ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
1: [2000-01-02 01:00:52.229] [Pid:(28849)]prepare took 1ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
2: [2000-01-02 00:55:05.383] [Pid:(28849)]executeForCursorWindow took 1ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
3: [2000-01-02 00:55:05.381] [Pid:(28849)]prepare took 0ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
4: [2000-01-02 00:54:59.346] [Pid:(28849)]executeForCursorWindow took 4ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
5: [2000-01-02 00:54:59.342] [Pid:(28849)]prepare took 0ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
6: [2000-01-02 00:53:36.684] [Pid:(28849)]executeForCursorWindow took 2ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
7: [2000-01-02 00:53:36.683] [Pid:(28849)]prepare took 1ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
8: [2000-01-02 00:50:25.537] [Pid:(28849)]executeForCursorWindow took 2ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
9: [2000-01-02 00:50:25.535] [Pid:(28849)]prepare took 0ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
10: [2000-01-02 00:48:49.561] [Pid:(28849)]executeForCursorWindow took 1ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
11: [2000-01-02 00:48:49.555] [Pid:(28849)]prepare took 2ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
12: [2000-01-02 00:47:16.757] [Pid:(28849)]executeForCursorWindow took 1ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
13: [2000-01-02 00:47:16.750] [Pid:(28849)]prepare took 2ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
14: [2000-01-02 00:37:01.959] [Pid:(0)]executeForCursorWindow took 0ms - succeeded, sql="PRAGMA database_list;"
15: [2000-01-02 00:37:01.958] [Pid:(0)]executeForLong took 0ms - succeeded, sql="PRAGMA page_size;"
16: [2000-01-02 00:37:01.957] [Pid:(0)]executeForLong took 1ms - succeeded, sql="PRAGMA page_count;"
17: [2000-01-02 00:10:22.402] [Pid:(28849)]executeForCursorWindow took 0ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
18: [2000-01-02 00:10:22.401] [Pid:(28849)]prepare took 0ms - succeeded, sql="SELECT * FROM skmessage WHERE isread = ?"
19: [2000-01-02 00:09:27.449] [Pid:(28849)]executeForCursorWindow took 0ms - succeeded, sql="SELECT * FROM skmessage WHERE localaccount = ? and remoteaccount = ? and isread = ?"
Available non-primary connections:
<none>
Acquired connections:
<none>
Connection waiters:
<none>
Attached db: false
j3y17qltecmcc:/ $
- adb install 文件路径
安装应用宝的apk文件 - adb uninstall [包名]
卸载指定包名的应用 - adb push [本地文件路径] [终端文件路径]
将本地文件推到终端 - adb pull [终端文件路径] [本地保存路径]
经终端文件或者文件拉取到本地 - adb shell screencap -p [保存路径]
截屏 - adb shell screenrecord [保存路径]
录制视频 adb shell screenrecord /sdcard/demo.mp4
备注:其实是需要adb shell 挂在终端上,然后执行 screenrecord 这个命令才行,不然会提示文件系统权限不够
- adb input text
输入文本内容到输入框
应用场景是:如果pc端有一大段文字需要输入到手机端的某个输入框,就可以通过这个命令经文字发送出去,前提是提前使edittext 控件获取到焦点
-
adb logcat
查看系统的当前日志,如果需要将日志保存,可以配合重定向 adb logcat > 保存路径 -
run-as
可以在非root设备中查看指定debug模式下的包名应用的沙盒数据 -
am startservive -n[service文件所在的绝对路径]�
启动一个服务
am startservice -n com.example.service.testservice
- am broadcast -a [action]�
发送一个广播
am broadcast -a com.example.action.test
如需携带参数
adb shell am broadcast -a com.android.test --es test_string "this is test string" --ei test_int 100 --ez test_boolean true
--es 是数据的类型为String ,key 值为 test_string velue 值为this is test string ,以此类推
-
ifconfig
查看设备的ip信息 -
netstat
查看设备的端口信息