当前位置:网站首页>Appium自动化测试基础 — adb shell 命令
Appium自动化测试基础 — adb shell 命令
2022-06-30 09:35:00 【测试-八戒】
Android系统是基于 Linux 内核的,也就是说Android系统的底层是Linux系统。所以 Linux 里的很多命令在 Android系统里也有相同或类似的实现,在 adb shell 里就可以调用。前面部分内容已经用到了 adb shell 命令,我们再来补充一下对adb shell 命令的认识。
提示:要在Android手机上执行的adb shell命令,就需要先root手机,而虚拟机是直接root的Android系统,所以直接可以在虚拟机上使用adb shell命令。
1、查看进程
命令:
adb shell ps输出示例:
USER PID PPID VSIZE RSS WCHAN PC NAME
root 1 0 8904 788 ffffffff 00000000 S /init
root 2 0 0 0 ffffffff 00000000 S kthreadd
...
u0_a71 7779 5926 1538748 48896 ffffffff 00000000 S com.sohu.inputmethod.sogou:classic
u0_a58 7963 5926 1561916 59568 ffffffff 00000000 S org.mazhuang.boottimemeasure
...
shell 8750 217 10640 740 00000000 b6f28340 R ps各列含义:
| 列名 | 含义 |
|---|---|
| USER | 所属用户 |
| PID | 进程 ID |
| PPID | 父进程 ID |
| NAME | 进程名 |
2、查看实时资源占用情况
命令:
adb shell top输出示例:
User 0%, System 6%, IOW 0%, IRQ 0%
User 3 + Nice 0 + Sys 21 + Idle 280 + IOW 0 + IRQ 0 + SIRQ 3 = 307
PID PR CPU% S #THR VSS RSS PCY UID Name
8763 0 3% R 1 10640K 1064K fg shell top
131 0 3% S 1 0K 0K fg root dhd_dpc
6144 0 0% S 115 1682004K 115916K fg system system_server
132 0 0% S 1 0K 0K fg root dhd_rxf
1731 0 0% S 6 20288K 788K fg root /system/bin/mpdecision
217 0 0% S 6 18008K 356K fg shell /sbin/adbd
...
7779 2 0% S 19 1538748K 48896K bg u0_a71 com.sohu.inputmethod.sogou:classic
7963 0 0% S 18 1561916K 59568K fg u0_a58 org.mazhuang.boottimemeasure
...各列含义:
| 列名 | 含义 |
|---|---|
| PID | 进程 ID |
| PR | 优先级 |
| CPU% | 当前瞬间占用 CPU 百分比 |
| S | 进程状态(R=运行,S=睡眠,T=跟踪/停止,Z=僵尸进程) |
| #THR | 线程数 |
| VSS | Virtual Set Size 虚拟耗用内存(包含共享库占用的内存) |
| RSS | Resident Set Size 实际使用物理内存(包含共享库占用的内存) |
| PCY | 调度策略优先级,SP_BACKGROUND/SPFOREGROUND |
| UID | 进程所有者的用户 ID |
| NAME | 进程名 |
top 命令还支持一些命令行参数,详细用法如下:
Usage: top [ -m max_procs ] [ -n iterations ] [ -d delay ] [ -s sort_column ] [ -t ] [ -h ]
-m num 最多显示多少个进程
-n num 刷新多少次后退出
-d num 刷新时间间隔(单位秒,默认值 5)
-s col 按某列排序(可用 col 值:cpu, vss, rss, thr)
-t 显示线程信息
-h 显示帮助文档3、查看进程 UID
有两种方案:
adb shell dumpsys package <packagename> | grep userId=
如:
$ adb shell dumpsys package org.mazhuang.guanggoo | grep userId=
userId=103942、 通过 ps 命令找到对应进程的 pid 之后 adb shell cat /proc/<pid>/status | grep Uid
如:
$ adb shell
gemini:/ $ ps | grep org.mazhuang.guanggoo
u0_a394 28635 770 1795812 78736 SyS_epoll_ 0000000000 S org.mazhuang.guanggoo
gemini:/ $ cat /proc/28635/status | grep Uid
Uid: 10394 10394 10394 10394
gemini:/ $4、其它adb shell 命令
如下是其它常用命令的简单描述,前文已经专门讲过的命令不再额外说明:
| 命令 | 功能 |
|---|---|
| cat | 显示文件内容 |
| cd | 切换目录 |
| chmod | 改变文件的存取模式/访问权限 |
| df | 查看磁盘空间使用情况 |
| grep | 过滤输出 |
| kill | 杀死指定 PID 的进程 |
| ls | 列举目录内容 |
| mount | 挂载目录的查看和管理 |
| mv | 移动或重命名文件 |
| ps | 查看正在运行的进程 |
| rm | 删除文件 |
| top | 查看进程的资源占用情况 |
和Linux系统中的命令基本上是一样的。
重点:配套学习资料和视频教学
那么在这里我也精心准备了上述大纲的详细资料在下方链接如下


边栏推荐
- prometheus 监控之 ntp_exporter
- MySQL internal component structure
- Clickhouse installation (quick start)
- JVM memory common parameter configuration set
- thrift简单使用
- JVM tuning tool introduction and constant pool explanation
- 【Ubuntu-redis安装】
- Train an image classifier demo in pytorch [learning notes]
- Redis docker master-slave mode and sentinel
- qmlplugindump executable not found.It is required to generate the qmltypes file for VTK Qml
猜你喜欢

MySQL-- Entity Framework Code First(EF Code First)

【AGC】构建服务3-认证服务示例

八大排序(一)
![[Ubuntu redis installation]](/img/66/d8054ae89007180b317641cf92d1cc.png)
[Ubuntu redis installation]

How can we have high performance and simple agility in the enterprise cloud on oracle?

Pytorch graduate warm LR installation

【新书推荐】MongoDB Performance Tuning

Mysq database remote connection error, remote connection is not allowed
![[new book recommendation] DeNO web development](/img/86/27906ae378e597cf64bb2d760a9dff.png)
[new book recommendation] DeNO web development

How to reduce the delay in live broadcast in the development of live broadcast source code with goods?
随机推荐
How to build an all-in-one database cloud machine that meets the needs of information innovation?
机器学习笔记 九:预测模型优化(防止欠拟合和过拟合问题发生)
Practice of super integration and transformation of core production business of public funds
JVM memory common parameter configuration set
Forrester senior analyst: five important trends in the development of the hyper convergence market
How can we have high performance and simple agility in the enterprise cloud on oracle?
Ocx control can be called by IE on some computers, but can not be called by IE on some computers
Dart 开发技巧
UltraEdit delete empty line method
ReturnJson,让返回数据多一些自定义数据或类名
How to build a private cloud and create a hybrid cloud ecosystem?
Numpy (time date and time increment)
Techtarget: Interpretation of the basic concept of super fusion cloud
Pass anonymous function to simplification principle
P. Summary of NP, NPC, NP hard and other issues
utils session&rpc
(zero) most complete JVM knowledge points
How do databases go to the enterprise cloud? Click to view the answer
Comparison problems encountered in recent study
仿照微信Oauth2.0接入方案