新手区 adb 常用操作

xinxi · 2018年08月05日 · 最后由 沙子 回复于 2018年08月06日 · 1958 次阅读

adb 相关命令

从 appium server 中的 log 日志提取的 adb 相关操作.

查看设备系统版本

shell getprop ro.build.version.release

out:6.0

查看设备中的 app 是否安装某个 app


shell pm list packages com.xueqiu.android

out: package:com.xueqiu.android

等待设备

wait-for-device

打印 ping

shell echo ping

查询 app 中的权限等信息

shell dumpsys package io.appium.settings

out: more app infomation

查询设备中 sdk 版本号

shell getprop ro.build.version.sdk

out:23

启动某个 app

包名/启动类

shell am start -W -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'

启动某个 app 前,先强制关闭

-S是强行关闭app参数 

shell am start -W -n com.xueqiu.android/.view.WelcomeActivityAlias -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000

赋予 app 模拟定位权限

appops set io.appium.settings android\:mock_location allow

安装 app

install UnicodeIME-debug.apk

获取输入法

shell settings get secure default_input_method

out:io.appium.android.ime/.UnicodeIME

设置输入法

shell ime enable io.appium.android.ime/.UnicodeIME'

获取设备屏幕尺寸

shell wm size

out:Physical size: 480x800

获取设备型号

shell getprop ro.product.model

out:Samsung Galaxy S6 - 6.0.0 - API 23 - 1440x2560

查询设备是模拟器还是真机

shell getprop ro.product.manufacturer

out:Genymotion

强行停止某个 app

shell am force-stop com.xueqiu.android

清除某个 app 数据

shell pm clear com.xueqiu.android

把设备转发到本地

forward tcp:4724 tcp:4724

把本地文件 push 到设备上


push 本地文件路径/手机设备文件夹路径

push /usr/local/lib/node_modules/appium/node_modules/appium-android-bootstrap/bootstrap/bin/AppiumBootstrap.jar /data/local/tmp/

查看手机设备上进程

shell ps

out:
shell     2757  268   698820 59108    ep_poll f731dd75 S com.android.shell
u0_a61    2791  268   1209988 198016    ep_poll f731dd75 S com.xueqiu.android
u0_a61    2844  268   1114452 125092    ep_poll f731dd75 S com.xueqiu.android:pushservice

查询设备上当前窗口信息

shell dumpsys window

out:    
Surface: shown=true layer=21015 alpha=1.0 rect=(0.0,0.0) 480.0 x 800.0
  Window #2 Window{b1145d7 u0 com.xueqiu.android/com.xueqiu.android.common.MainActivity}:

模拟设备上事件

input keyevent 3 home键

input keyevent 4 back键

需要 登录 後方可回應,如果你還沒有帳號按這裡 注册