獲取 App 的信息
App 信息
- 獲取當(dāng)前界面元素:adb shell dumpsys activity top
- 獲取任務(wù)列表:adb shell dumpsys activity activities
App 入口
- adb logcat |grep -i displayed
- aapt dump badging mobike.apk | grep launchable-activity
- apkanalyzer 最新版本的 SDK 中才有
啟動(dòng)應(yīng)用
- adb shell am start -W -n com.xueqiu.android/.view.WelcomeActivityAlias -S
Android 常用命令
- adb:Android Debug Bridge
- adb devices:查看設(shè)備
- adb kill-server:關(guān)閉 adb 的后臺進(jìn)程
- adb tcpip:讓 Android 脫離 USB 線的 TCP 連接方式
- adb connect:連接開啟了 TCP 連接方式的手機(jī)
- adb logcat:Android 日志查看
- adb bugreport:收集日志數(shù)據(jù)吁津,用于后續(xù)的分析,比如耗電量
adb shell
adb shell 本身就是一個(gè) Linux 的 shell跪解,可以調(diào)用 Android 內(nèi)置命令
adb shell
- adb shell dumpsys
- adb shell pm
- adb shell am
- adb shell ps
- adb shell monkey
測試常用命令
- adb
- pm
- am
- dumpsys
- uiautomator
- input
Android 性能統(tǒng)計(jì) dumpsys
- 獲取所有的 dumpsys 子命令 dumpsys | grep -i DUMP
- 獲取當(dāng)前 activity adb shell dumpsys activity top
- 獲取 activities 的記錄絮短,可以獲取到 appium 依賴的原始 activity dumpsys activity activities
- 獲取特定包基本信息 adb shell dumpsys package com.xueqiu.android
- 獲取系統(tǒng)通知 adb shell dumpsys noti?cation
- 獲得內(nèi)存信息 adb shell dumpsys meminfo com.android.settings
- 獲取 cpu 信息 adb shell dumpsys cpuinfo
- 獲取 gpu 繪制分析 adb shell dumpsys gfxinfo com.android.settings
- 獲取短信 adb shell dumpsys activity broadcasts | grep senderName=
uiautomator
- adb shell uiautomator runtest ...
- adb shell uiautomator dump
簡單的自動(dòng)化工具 adb shell input 命令
- text <string> (Default: touchscreen)
- keyevent [--longpress] <key code number or name> ... (Default: keyboard)
- tap <x> <y> (Default: touchscreen)
- swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
- draganddrop <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
- press (Default: trackball)
- roll <dx> <dy> (Default: trackbal