• adb控制常用命令


    # adb 帮助
    adb 	--help
    # 启动adb 服务
    adb 	start-server
    # 关闭adb服务
    adb	kill-server
    # 获取设备号
    adb 	devices		
    # 获取系统版本号	
    adb shell getprop ro.build.version.release   
    # 发送PC文件到手机端
    adb push C:\Users\XXX\Desktop\xx.png  /sdcard
    # 手机端拉取到PC
    adb pull /sdcard/xx.png C:\Users\XXX\Desktop
    # 进入手机命令行
    adb shell 
    adb -s 192.168.11.102:5555 shell    # 进入指定的设备
    # 主动连接设备,设备名
    adb connect 设备名
    adb connect 127.0.0.1:62001     # 4.1版本
    # 主动断开连接
    adb disconnect 设备名     
    # 安装卸载app
    adb install 路径/xx.apk
    adb uninstall 包名
    # 获取包名启动名
    adb shell dumpsys window windows | findstr mFocusedApp
    aapt dump badging 安装包路径 【只有安装包获取包名与启动】
    # 获取手机运行日志
    adb logcat
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    1. 获取内部版本号: adb shell getprop ro.build.display.innerver
    2. 获取按键值: adb shell getevent
    3. 获取apk信息: adb shell dumpsys package 包名 ->info.txt
    4. 获取应用包名:adb shell dumpsys window windows | grep mFocusedApp  或者 adb shell dumpsys window windows | findstr mFocusedApp
    5. 打开WiFi设置界面:adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
    6. 打开热点设置界面:adb shell am start -n com.android.settings/.TetherSettings
    7. 查询蓝牙是否开启:
    adb shell settings get global bluetooth_on   返回结果0代表关闭,1代表开启
    adb shell dumpsys bluetooth_manager | findstr enabled     返回结果是true或者false,说明开启或关闭
    8. 查询WiFi是否开启:adb shell settings get global wifi_on     返回结果0代表关闭,1代表开启 
    9. 查询蓝牙地址:adb shell settings get secure bluetooth_address
    10. 查询WiFi地址:adb shell cat /sys/class/net/wlan0/address
    11. 开启WiFi:adb shell svc wifi enable
    12. 关闭WiFi:adb shell svc wifi disable
    13. 打开蓝牙设置界面:adb shell am start -a android.settings.BLUETOOTH_SETTINGS
    14. 获取手机休眠时间:adb shell settings get system screen_off_timeout
    15. 更改手机休眠时间:adb shell settings put system screen_off_timeout 60000010分钟)
    16. 获取系统默认输入法:adb shell settings get secure default_input_method
    17. 获取手机是否为自动亮度:adb shell settings get system screen_brightness_mode  (0代表非自动,1代表为自动)
    18. 设置手机为自动调整亮度:adb shell settings put system screen_brightness_mode 1    
    19. 获取手机当前亮度:adb shell settings get system screen_brightness
    20. 设置手机亮度(0-255):adb shell settings put system screen_brightness 350
    21. 打开定位设置界面:adb shell am start -a android.settings.LOCATION_SOURCE_SETTINGS
    22. 开启定位:adb shell settings put secure location_providers_allowed +gps
    23. 关闭定位:adb shell settings put secure location_providers_allowed -gps
    24. 查看定位方式:adb shell settings get secure location_providers_allowed  (前提是位置信息开启)
    25. 拨打电话:adb shell am start -a android.intent.action.CALL tel:8888888888888
    26. 发送短信:adb shell am start -a android.intent.action.SENDTO -d sms:10086(发送目的号码) --es sms_body "hello"(短信内容) --ez exit_on_sent true 
    27. 获取应用包名:adb shell dumpsys window windows | findstr  mFocusedApp 
    28. 清除应用数据与缓存: adb shell pm clear cn.com.test.mobile
    29. 启动应用: adb shell am start -n cn.com.test.mobile/.ui.SplashActivity 
    30. 停止应用:adb shell am force-stop cn.com.test.mobile
    31. 飞行模式:adb shell settings set global airplane_mode_on   (0==关闭,1==开启)
    32. 开启飞行模式:adb shell settings put global airplane_mode_on 1
    33. 手机震动测试(前提手机root):①adb shell ②echo '3000'>/sys/devices/virtual/timed_output/vibrator/enable
    34. 向上滑:adb shell input touchscreen swipe 930 880 930 380 
    35. 向下滑:adb shell input touchscreen swipe 930 380 930 880
    36. 向右滑:adb shell input touchscreen swipe 330 880 930 880 
    37. 向左滑:adb shell input touchscreen swipe 930 880 330 880
    38. 模拟鼠标点击操作:adb shell input mouse tap 100 500
    39. 长按:adb shell input swipe startX startY startX startY 500
    40. 滑动解锁:adb shell input swipe 300 1000 300 500
    41. 冷启动app:adb shell am start -W -n package/activity
    42. 热启动:①停止app: adb shell input keyevent 3  ②adb shell am start -W -n package/activity
    43. 查看内存占用情况:adb -s 设备号 shell top -m 进程数量 -n 数据的刷新次数 -s 按哪列进行排序 -d 刷新时间间隔(默认5秒)
    44. 切换手机电池为非充电状态: adb shell dumpsys battery set status 1
    45. 改变手机电量: adb shell dumpsys battery set level 58
    46. 获取当前电量:adb shell cat /sys/class/power_supply/battery/capacity
    47. 手机截屏:adb shell /system/bin/screencap -p /sdcard/screenshot.png
    48. 录制屏幕:adb shell screenrecord --time-limit 10 /sdcard/demo.mp4
    49. 获取手机型号:adb shell getprop ro.product.model
    50. 获取电池信息:adb shell dumpsys battery  
    51. 获取屏幕分辨率:adb shell wm size
    52. 获取屏幕密度:adb shell wm density
    53. 显示屏参数:adb shell dumpsys window displays
    54. 获取手机IP地址:adb shell ifconfig | findstr Mask
    55. 查看WiFi局域网地址:adb shell ifconfig wlan0
    56. 显示区域位置:adb shell wm overscan 0,0,0,200  (四个数字分别表示距离左、上、右、下边缘的留白像素,以上命令表示将屏幕底部 200px 留白)
    57. 恢复原显示区域命令:adb shell wm overscan reset
    58. 获取USB调试模式:adb shell settings get global adb_enabled
    59. 关闭USB调试模式:adb shell settings put global adb_enabled 0
    60. 状态栏和导航栏的显示隐藏:
    adb shell settings put global policy_control <key-values>
    <key-values> 可由如下几种键及其对应的值组成,格式为 <key1>=<value1>:<key2>=<value2>。
      immersive.full----------同时隐藏
      immersive.status----------隐藏状态栏
      immersive.navigation----------隐藏导航栏
      immersive.preconfirms----------?
    这些键对应的值可则如下值用逗号组合:
      apps----------所有应用
      *----------所有界面
      packagename----------指定应用
     -packagename----------排除指定应用
    例如:
    adb shell settings put global policy_control immersive.full=*
    表示设置在所有界面下都同时隐藏状态栏和导航栏。
    adb shell settings put global policy_control immersive.status=com.package1,com.package2:immersive.navigation=apps,-com.package3
    表示设置在包名为 com.package1 和 com.package2 的应用里隐藏状态栏,在除了包名为 com.package3 的所有应用里隐藏导航栏。
    61. 打开网页: adb shell am start -a android.intent.action.VIEW -d http://www.baidu.com
    62. 查看通信日志 :adb logcat -b radio (常用于查看详细的通话状态)
    63. 获取界面控件:adb uiautomator dump
    64. 列出输入法:adb shell ime list -s 
    65. 永不休眠:adb shell settings put system screen_off_timeout 2147483647
    66. 关闭\打开自动旋转:adb shell settings put system accelerometer_rotation 0\1
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    ADB命令启动WiFi
    初始操作:
    insmod /system/lib/modules/wlan.ko       //加载驱动模块
    start wpa_supplicant                                //启动wpa_supplicant 
    
    扫描热点:
    
    wpa_cli -iwlan0 scan
    wpa_cli -iwlan0 scan_results
    
    添加热点:
    
    wpa_cli -iwlan0 add_network  0
    wpa_cli -iwlan0 set_network   0  ssid "360wifi"
    wpa_cli -iwlan0 set_network   0  psk "123456"
    wpa_cli -iwlan0 save_config
    
    wpa_cli -iwlan0 add_network  1
    wpa_cli -iwlan0 set_network   1  ssid "360wifi2"
    wpa_cli -iwlan0 set_network    1  psk  "000000"
    wpa_cli -iwlan0 save_config
    
    连接wifi:
    wpa_cli -iwlan0 list_network                     //列出可用wifi
    wpa_cli -iwlan0 select_network  0            //选择第0个热点
    wpa_cli -iwlan0 enable_network 0           //使能第0个热点
    dhcptool wlan0                                         //启用动态地址分配
    
    断开wifi:
    ifconfig wlan0 down
    killall wpa_supplicant   
    
    删除已保存热点:
    wpa_cli -iwlan0 list_network
    wpa_cli -iwlan0 remove_network 0       //删除第0个热点
    wpa_cli -iwlan0  save_config
    
    其他:
    
    保存的热点信号存储在路径/data/misc/wifi/wpa_supplicant.conf
    
    start wpa_supplicant启动的服务在如下:
    device/qcom/common/rootdir/etc/init.qcom.rc
    
    service wpa_supplicant /system/bin/wpa_supplicant \
        -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
        -I/system/etc/wifi/wpa_supplicant_overlay.conf \
        -O/data/misc/wifi/sockets -dd \
        -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
        #   we will start as root and wpa_supplicant will switch to user wifi
        #   after setting up the capabilities required for WEXT
        #   user wifi
        #   group wifi inet keystore
        class main
        socket wpa_wlan0 dgram 660 wifi wifi
        disabled
        oneshot
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
  • 相关阅读:
    我开发了一个利用 Bun 执行 .ts / .js 文件的 VS Code 插件
    tcp拥塞控制原理
    照片太大怎么缩小kb?
    图相似度计算——SIMGnn源码解读
    架构师的 36 项修炼第10讲:架构实战案例分析
    无线渗透_COWPATTY破解密码
    Python编程从入门到实践 第十章:文件和异常 练习答案记录
    本地电脑搭建web服务器、个人博客网站并发布公网访问 【无公网IP】(1)
    C++ primer 5th笔记
    C. Link Cut Centroids(树的重心性质)
  • 原文地址:https://blog.csdn.net/weixin_37787043/article/details/126130634