zoukankan      html  css  js  c++  java
  • adb命令的一些补充

    如上-e代表push到模拟器中,/mnt/sdcard/代表SD卡

    adb logcat wait-for-device等待设备一连接就开始抓LOG

     

    从电脑上远程控制手机

    打开设备上的monkey端口

    将PC的1080端口印射到手机上的1080端口上,这样所有通过电脑1080端口的信息都会发住手机

    远程连接电脑上的端口,比如发送一些按键信息,这样就能传递到手机上了

    adb 无线连接与文件同步

    adb connect + IP ,可以链接某个设备。

       这个命令在调试真机的时候,使用频繁。
    
     但注意:
    
       1.要链接的IP ,必须和自己的PC的网络在同一个局域网内,adb 不能跨局域网链接设备
    
       2.如果通过usb链接android设备,通过adb devices 可以看见设备列表,但是使用不了,可以参考下面的命令
    
     
    
    adb tcpip 5555
    adb connect 192.168.0.101:5555

    adb shell getprop dhcp.wlan0.ipaddress获取设备的IP地址

    adb get-serialno   获取设备的ID和序列号serialNumber 

    说明: 
    序列号[serialNumber]——由adb创建的一个字符串,这个字符串通过自己的控制端口<type>-<consolePort> 
    唯一地识别一个模拟器/设备实例。一个序列号的例子: emulator-5554 

    adb get-state  查看模拟器/设施的当前状态.

    adb forward <local> <remote>发布端口,可以设置任意的端口号, 
    adb forward tcp:6100 tcp:7100 // PC上所有6100端口通信数据将被重定向到手机端7100端口server上

    adb wait-for-device 在模拟器/设备连接之前把命令转载在adb的命令器中 

    adb jdwp 查看指定的设施的可用的JDWP信息. 

    adb shell input text <string>  向设备输入文本(光标所在的文本框) 

    adb shell input keyevent <event_code> 向设备发送按键事件 

    input tap , 对屏幕发送一个触摸事件

    adb shell input tap 500 500

    input swipe , 滑动事件

    adb shell input swipe 900 500 100 500
     

    在编辑短信时,往文本框输入文本:adb shell input text "hello"  
    向手机发送键值回Home:adb shell input keyevent 3 
    event_code 参考view/KeyEvent.java中的  KEYCODE_* 
        public static final int KEYCODE_SOFT_LEFT       = 1; 
        public static final int KEYCODE_SOFT_RIGHT      = 2; 
        public static final int KEYCODE_HOME            = 3; 
        public static final int KEYCODE_BACK            = 4; 
        public static final int KEYCODE_CALL            = 5; 
        public static final int KEYCODE_ENDCALL         = 6; 

    adb shell procrank 查询各进程内存使用情况 
    adb shell service list 查看services信息 
    adb shell cat /proc/meminfo 查看当前的内存情况 
    adb shell cat /proc/cpuinfo 查看CPU信息(硬件) 
    adb shell cat /proc/iomem  查看IO内存分区 

    adb shell getprop 列出系统所有属性 
    adb shell getprop | findstr "gsm" 列出包含gsm的属性 
    adb shell setprop <key> <value>  修改系统属性 
      
    adb shell sqlite3 可以执行sql语句查看数据库信息, 具体使用情况待调查 

    adb shell dmesg     查询内核缓冲区信息 
    adb shell dumpstate 各类信息,比如进程信息,内存信息,进程是否异常,kernnel的log等 
    adb shell dumpcrash 
    adb shell dumpsys  查询所有service的状态 

    adb reboot-bootloader 重启到bootloader 
    adb reboot recovery 重启到recovery 

    adb push flash_image.zip /system/bin/flash_image 增加flash_image文件到手机上 

    android list targets 显示系统中全部Android平台

    android list avd  显示系统中全部AVD(模拟器): 
    adb shell screencap -p /sdcard/penghong.png(参数-p为保存为png格式)

    adb shell screenrecord /sdcard/demo.mp4 录制视频

    adb shell pm dump com.tencent.mobileqq 列出指定应用的 dump 信息

    adb shell pm install , 安装应用存放于 Android 设备上(安装存放于电脑上的用adb install)

    am
    
    又是一个庞大的命令。。。
    
    am 源码 Am.java
    
    am start , 启动一个 Activity,已启动系统相机应用为例
    
    启动相机
    [xuxu:~]$ adb shell am start -n com.android.camera/.Camera
    Starting: Intent { cmp=com.android.camera/.Camera }
    先停止目标应用,再启动
    [xuxu:~]$ adb shell am start -S com.android.camera/.Camera
    Stopping: com.android.camera
    Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]     cmp=com.android.camera/.Camera }
    等待应用完成启动
    [xuxu:~]$ adb shell am start -W com.android.camera/.Camera
    Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.android.camera/.Camera }
    Status: ok
    Activity: com.android.camera/.Camera
    ThisTime: 500
    TotalTime: 500
    Complete
    启动默认浏览器打开一个网页
    [xuxu:~]$ adb shell am start -a android.intent.action.VIEW -d http://testerhome.com
    Starting: Intent { act=android.intent.action.VIEW dat=http://testerhome.com }
    启动拨号器拨打 10086
    [xuxu:~]$ adb shell am start -a android.intent.action.CALL -d tel:10086            
    Starting: Intent { act=android.intent.action.CALL dat=tel:xxxxx }
    am instrument , 启动一个 instrumentation , 单元测试或者 Robotium 会用到
    am monitor , 监控 crash 与 ANR
    
    [xuxu:~]$ adb shell am monitor
    Monitoring activity manager...  available commands:
    (q)uit: finish monitoring
    ** Activity starting: com.android.camera
    am force-stop , 后跟包名,结束应用
    am startservice , 启动一个服务
    am broadcast , 发送一个广播
    

    adb shell uiautomator dump 获取当前界面的控件信息

    adb shell ime list -s 列出设备上的输入法

    adb shell wm size 获取手机分辨率

    adb shell settings https://testerhome.com/topics/1993

    adb shell dumpsys dropbox [--print|--file] [YYYY-mm-dd] [HH:MM:SS] [tag]  app发生crash,未及时在logcat中抓取到有效log时,可通过该脚本获取到log,app报错时间关键字“data_app_crash”

    adb shell dumpsys package com.tencent.mm|findstr android.permission获取应用的权限

    8.获取通知信息:

    adb shell dumpsys notification

    7.adb shell dumpsys wifi

    可以获取到当前连接的wifi名、搜索到的wifi列表、wifi强度等
    

    获取电源管理信息:

    adb shell dumpsys power
    可以获取到是否处于锁屏状态:mWakefulness=Asleep或者mScreenOn=false
    亮度值:mScreenBrightness=255
    屏幕休眠时间:Screen off timeout: 60000 ms
    屏幕分辨率:mDisplayWidth=1440,mDisplayHeight=2560
    等
    

    获取电话信息:

    adb shell dumpsys telephony.registry
    可以获取到电话状态,例如
    mCallState值为0,表示待机状态、1表示来电未接听状态、2表示电话占线状态
    mCallForwarding=false #是否启用呼叫转移
    mDataConnectionState=2 #0:无数据连接 1:正在创建数据连接 2:已连接
    mDataConnectionPossible=true  #是否有数据连接
    mDataConnectionApn=   #APN名称
    等

    adb shell dumpsys window displays |findstr init 获取手机分辨率
    使用命令adb  shell dumpsys alarm 来检测app的alarm唤醒次数

    adb 获取WIFI密码:adb shell后,然后 cat /data/misc/wifi/*.conf命令

    手机不识卡的解决办法:adb shell setprop persist.radio.multisim.config dsds

    adb shell getprop dalvik.vm.heapgrowthlimit单个应用程序最大内存限制

    adb shell dumpsys battery set usb 0 屏蔽USB充电

    cat /proc/stat命令 查看CPU时间片

    查看 TP相关的信息

    adb shell getevent    查看input设备属于哪一个event

    adb shell getevent dev/input/event1

    与input event 对应的信息 root@android:/ # cat/proc/bus/input/devices

    查看TP上报的速率: getevent -r /dev/input/event1
    查看TP上报的键值:getevent -l/dev/input/event1

    /system/build.prop中 JAVA虚拟机内存使用上限,还可以adb shell getprop查看

    adb shell getprop|findstr dalvik.vm.heapgrowthlimit 

    adb logcat -c 清空手机中的log

    单个应用程序最大内存限制,超过这个值会产生OOM

    adb shell cat /system/build.prop>phone.info

     ro.build.version.release  android版本号

    ro.product.model 机型

     ro.product.brand分支

    adb shell pm clear com.android.contacts清除数据

    adb nodaemon server查看adb的端口号

  • 相关阅读:
    Sqlite Administrator
    在资源管理器/我的电脑详细信息视图里按下Ctrl+(小键盘+)
    Asp.net 2.0 Membership Provider for db4o 6.1
    测试使用Zoundry发布blog
    我的WCF之旅(8):WCF中的Session和Instancing Management
    我的WCF之旅(7):面向服务架构(SOA)和面向对象编程(OOP)的结合——如何实现Service Contract的继承
    我的WCF之旅(5):面向服务架构(SOA)和面向对象编程(OOP)的结合——如何实现Service Contract的重载(Overloading)
    我的WCF之旅(4):WCF中的序列化[上篇]
    我的WCF之旅(6):在Winform Application中调用Duplex Service出现TimeoutException的原因和解决方案
    我的WCF之旅(4):WCF中的序列化[下篇]
  • 原文地址:https://www.cnblogs.com/penghong2014/p/4959449.html
Copyright © 2011-2022 走看看