adb shell
查看设备
adb devices
List of devices attached
5ecf5fbc device
连接设备
# 单个设备
adb shell
# 多个设备需要指定
adb -s 5ecf5fbc shell
安装APP
adb install -r demo.apk
# 分包安装
pm install-create
Success: created install session [517717390]
pm install-write 517717390 base0.apk demo-main.apk
pm install-write 517717390 base1.apk demo-main-res1.apk
pm install-write 517717390 base2.apk demo-main-res2.apk
pm install-commit 517717390
或者
adb install-multiple base.apk config.armeabi_v7a.apk config.es.apk
//base.apk是主包,得放在最前面
启动组件
# 启动activity
am start -n com.demo/com.demo.MainActivity
# 启动service
am startservice -n com.demo/com.demo.MyService
# 发送广播
am broadcast -a android.intent.action.USER_PRESENT -f 32
清除
pm clear <packagename>
强制关闭app
am force-stop <packagename>
跳转Google Play
am start -a android.intent.action.VIEW -d "market://details?id=com.demo"
浏览器打开url
am start -a android.intent.action.VIEW -d "https://www.demo.com"
截屏
screencap -p /sdcard/screen.png
录屏
screenrecord --size 1920x480 --time-limit 100 /sdcard/screen.mp4
获取AndroidId
settings get secure android_id
# 或者查询 Settings 的 content provider 的值
content query --uri content://settings/secure/android_id
获取apk路径
pm path com.demo
获取应用信息
dumpsys package com.tencent.mobileqq
# 或者
pm dump com.tencent.mobileqq
挂载
mount -o remount,rw /system
获取当前Activity
dumpsys activity | grep mFocusedActivity
#6.0以上使用下面的
dumpsys activity | grep mResumedActivity
获取文件MD5
md5sum -b com.demo.apk
获取rom版本
getprop ro.modversion
ui dump
uiautomator dump /sdcard/uidump.xml
获取分辨率
wm size
# 详细数据
dumpsys window displays
获取包的uid
dumpsys package <packagename> | grep userId
标签:shell,demo,apk,adb,install,com,pm
From: https://www.cnblogs.com/davidlee1219/p/16923518.html