ADB学习02-2022-01-09

学习目标:学习ADB基本语法

14.获取某个包名的启动入口
adb shell dumpsys package 包名 | findstr activity

aosp:/ # dumpsys package com.bilibili.fatego|grep -i 'activity'
Activity Resolver Table:
        100bd02 com.bilibili.fatego/.UnityPlayerNativeActivity filter 46a6ed9
        8734613 com.bilibili.fatego/com.sina.weibo.sdk.share.WbShareResultActivity filter 184177f
      com.sina.weibo.sdk.action.ACTION_SDK_REQ_ACTIVITY:
        8734613 com.bilibili.fatego/com.sina.weibo.sdk.share.WbShareResultActivity filter 3ed809e
          Action: "com.sina.weibo.sdk.action.ACTION_SDK_REQ_ACTIVITY"

这里用的是grep搜索,我比较熟悉(注意CMD用不了GREP,只能先进ADB shell)
15.启动某个APP
adb shell am start -n [包名]/[启动入口]

C:\Users\le>adb shell dumpsys package  com.qihoo.appstore|findstr Activity
Activity Resolver Table:
        4aaa38 com.qihoo.appstore/.keepalive.channel.StartProxyActivity filter a582bc3
        ef7ba11 com.qihoo.appstore/.home.MainActivity filter 9f8ee2f
        4519776 com.qihoo.appstore/.bgjump.BgEmptyActivity filter 1ed3570
        e27a177 com.qihoo.appstore/.home.LauncherActivity filter fe2131a
        31c31e4 com.qihoo.appstore/com.tencent.tauth.AuthActivity filter 5b54cbe
        48ce64d com.qihoo.appstore/.uninstallretain.UninstRetainLauncherActivity filter 4f1503b

先用上一步找到启动入口

C:\Users\le>adb shell am start -n com.qihoo.appstore/.keepalive.channel.StartProxyActivity filter
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] pkg=filter cmp=com.qihoo.appstore/.keepalive.channel.StartProxyActivity }

这里显示starting,但是在模拟器上没看见对应APP启动。XD

C:\Users\le>adb shell am start -n com.qihoo.appstore/.home.MainActivity filter
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] pkg=filter cmp=com.qihoo.appstore/.home.MainActivity }

启动入口太多,这里的home.MainActivity才是主要的启动APP的入口
16.屏幕截图
adb shell screencap [保存路径]

C:\Users\le>adb shell screencap sdcard/Documents/screen01.png

注意:adb shell screencap的保存路径,要精确到文件,而不是文件夹;
17.屏幕录像
adb shell screenrecord [保存路径]

C:\Users\le>adb shell screenrecord /sdcard/Demo.mp4

可以用ctrl + C 来停止录像
18.上传和下载文件到手机
adb push 推入文件 (上传)

adb pull 拉出文件(下载)

C:\Users\le>adb pull sdcard/Demo.mp4 C:\Users\le\Desktop
sdcard/Demo.mp4: 1 file pulled. 3.8 MB/s (93447 bytes in 0.023s)
C:\Users\le>adb push C:\Users\le\Desktop\Maohuan\adb_learn\adb_SCREEN\screen01.png sdcard/
C:\Users\le\Desktop\Maohuan\adb_learn\adb_SCREEN\screen01.png: 1 file pushed. 15.7 MB/s (1003923 bytes in 0.061s)
C:\Users\le>adb shell "ls -l sdcard/|grep -i 'Demo'"
-rw-rw---- 1 root sdcard_rw   93447 2022-01-09 23:32 Demo.mp4
C:\Users\le>adb shell "ls -l sdcard/|grep -i 'screen'"
-rw-rw---- 1 root sdcard_rw 1003923 2022-01-09 23:27 screen01.png

19.模拟屏幕点击事件
adb shell input tap x坐标轴 y坐标轴
先查看adb shell wm size

C:\Users\le>adb shell wm size
Physical size: 1080x1920

查看点击范围

C:\Users\le>adb shell input tap 500 1500

20.模拟手势滑动事件
adb shell input swipe 开始x轴 开始y轴 结束x轴 结束y轴 过程持续时间毫秒

C:\Users\le>adb shell input swipe 0 0 500 1500 5

21.模拟点按实体按键或键盘
adb shell input keyevent [key值]

C:\Users\le>adb shell keyevent 26
/system/bin/sh: keyevent: not found

模拟器没有keyevent,如果是真实手机的话,这里26应该是电源键
22.向屏幕输入信息
adb shell input text [字符串信息]
字符串信息要用引号引起来
%s为空格

C:\Users\le>adb shell input text "hello%smy%sphone"

23.发送广播
adb shell am broadcast -a “broadcastactionfilter”

C:\Users\le>adb shell am broadcast -a "hello%smy%sphone"
Broadcasting: Intent { act=hello%smy%sphone }
Broadcast completed: result=0

24.重启手机
adb reboot
重启到recovery
adb reboot recovery
重启到bootloader界面(有一些特定的操作需要用到)
adb reboot bootloader

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值