获取手机信息

原文: Android 通过adb获取手机信息
1、获取手机系统信息( CPU,厂商名称等)
adb shell "cat /system/build.prop | grep "product""

2、获取手机系统版本
adb shell getprop ro.build.version.release

3、获取手机系统api版本
adb shell getprop ro.build.version.sdk

4、获取手机设备型号
adb -d shell getprop ro.product.model

5、获取手机厂商名称
adb -d shell getprop ro.product.brand

6、获取手机的序列号
有两种方式

1、 adb get-serialno

2、 adb shell getprop ro.serialno

7、获取手机的IMEI
有三种方式,由于手机和系统的限制,不一定获取到

1、 adb shell dumpsys iphonesubinfo

其中Device ID即为IMEI号

2、 adb shell getprop gsm.baseband.imei

3、 service call iphonesubinfo 1

此种方式,需要自己处理获取的信息得到

8、获取手机mac地址

adb shell cat /sys/class/net/wlan0/address

9、获取手机内存信息
adb shell cat /proc/meminfo

10、获取手机存储信息
adb shell df

获取手机内部存储信息:

魅族手机: adb shell df /mnt/shell/emulated

其他: adb shell df /data

获取sdcard存储信息:

adb shell df /storage/sdcard

11、获取手机分辨率
adb shell "dumpsys window | grep mUnrestrictedScreen"

12、获取手机物理密度
adb shell wm density


作者:csky6688
来源:CSDN
原文:https://blog.csdn.net/fasfaf454/article/details/51438743
版权声明:本文为博主原创文章,转载请附上博文链接!

adb shell input text

输入一个字符串,只支持英文数字和部分符号
当需要为一个控件输入内容时,需要先保证输入框正片处于焦点

adb shell dumpsys activty | grep -i mSleeping

判断当前屏幕状态

adb shell dumpsys cpuinfo

adb shell top -s cpu

获取手机cpu信息

adb shell am start packageName/className

启动一个Activity

adb shell am broadcast

发送一个广播,使用-a来指定Action,-d指定数据

adb shell am broadcast -a 'com.icechao.broadcast'
adb shell am am force-stop packageName

强制停止一个应用

adb shell pm clear packageName

清理应用数据

adb shelll kill pid

杀死某个进程

adb logcat -v time -d

打印logcat

adb shell df

文件系统的磁盘空间占用情况

adb shell /system/bin/screencap -p /sdcard/screenshot.png

手机截屏

adb shell screenrecord --time-limit 10 /sdcard/demo.mp4

录制屏幕

adb shell getprop dhcp.wlan0.ipaddress

获取手机ip地址

cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq

获取手机Cpu最小频率

cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq

获取手机Cpu最大频率

cat /sys/devices/system/cpu/cpu0/cpufreq/kernel_max

获取手机cpu核数

adb shell dumpsys window policy | grep mScreenOnFully

获取手机屏幕策略,windows中需要不能使用grep命令筛选信息

adb shell dumpsys window policy | grep mShowingLockscreen

判断当前手机是否是锁屏状态

adb shell svc wifi enable/disable

打开手机wifi,实测部份三星手机不支持些方法
adb shell monkey

能过monkey植入事件为app进行压力测试

grep(命令中 ' | '到命名结束的部份)命令可以从得到的结果里筛选想要的信息行,这个命令只支持linux 在windows可以考虑使用findstr

在进入手机shell模式后很多通用命令是和linux是一样的,所以可以直接使用linux命令来获取手机的信息

当电脑连接多台手机使用 adb -s 手机序列号 命令 的方式指定手机

作者:icechao
链接:https://www.jianshu.com/p/e024e24ae581
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

adb shell intput swipe left top right bottom

植入屏幕滑动事件
左上为滑动的起始位置,右下为滑动的结束位置
adb shell input swipe 100 200 500 300

adb shell input tap

植入屏幕点击事件,先X轴再Y轴

adb shell input tap 100 200

界面控制

通过adb发送文字

adb shell input text "asdb"

虽然这一篇要求必须得出坐标才能点击 https://stackoverflow.com/questions/18924968/using-adb-to-access-a-particular-ui-control-on-the-screen
但似乎monkeyrunner可以根据ID点击 https://developer.android.com/studio/test/monkeyrunner , 类似下面这段:

# Presses the Menu button
device.press('KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP)

标签: none 阅读量: 884

添加新评论