Android 使用adb操作WiFi相关指令

这篇具有很好参考价值的文章主要介绍了Android 使用adb操作WiFi相关指令。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

没有系统原生设置应用又需要调试WiFi功能时,可以使用如下指令来验证WiFi相关功能

最常用的就是 svc wifi enable/disable,再使用wpa_supplicant/wpa_cli来验证,但对于AP功能就没办法验证了,其实Android有组很强大的shell指令集,包含各个方便,这里只记录下平时使用的WiFi相关指令

1、adb shell cmd wifi -h

查看WiFi所有指令以及参数

2、打开关闭WLAN

adb shell cmd wifi set-wifi-enabled enabled

adb shell cmd wifi set-wifi-enabled disabled

3、扫描WiFi

adb shell cmd wifi start-scan             //扫描

adb shell cmd wifi list-scan-results    //查看扫描结果

4、连接WiFi

adb shell cmd wifi connect-network TP-LINK_5G_0FE1 wpa2 12345678

//TP-LINK_5G_0FE1 连接WiFi名称

//wpa2 加密方式

//12345678 密码

5、查看WiFi状态

adb shell cmd wifi status

6、打开关闭热点

adb shell cmd wifi start-softap ap_ssidxx wpa2 12345678 -b5

// ap_ssidxx  热点名称

// wpa2 加密方式

//12345678 密码

//-b5 5G频段

adb shell cmd wifi stop-softap

其他可以指令可以使用adb shell cmd wifi -h查看,如果需要连接WiFi以外的相关指令可以使用adb shell cmd -l(小写L)文章来源地址https://www.toymoban.com/news/detail-841002.html

Wi-Fi (wifi) commands:
  help or -h
    Print this help text.
  get-country-code
    Gets country code as a two-letter string
  set-wifi-enabled enabled|disabled
    Enables/disables Wifi on this device.
  set-scan-always-available enabled|disabled
    Sets whether scanning should be available even when wifi is off.
  list-scan-results
    Lists the latest scan results
  start-scan
    Start a new scan
  list-networks
    Lists the saved networks
  connect-network <ssid> open|owe|wpa2|wpa3 [<passphrase>] [-m] [-d] [-b <bssid>]
    Connect to a network with provided params and add to saved networks list
    <ssid> - SSID of the network
    open|owe|wpa2|wpa3 - Security type of the network.
        - Use 'open' or 'owe' for networks with no passphrase
           - 'open' - Open networks (Most prevalent)
           - 'owe' - Enhanced open networks
        - Use 'wpa2' or 'wpa3' for networks with passphrase
           - 'wpa2' - WPA-2 PSK networks (Most prevalent)
           - 'wpa3' - WPA-3 PSK networks
    -m - Mark the network metered.
    -d - Mark the network autojoin disabled.
    -b <bssid> - Set specific BSSID.
  add-network <ssid> open|owe|wpa2|wpa3 [<passphrase>] [-m] [-d] [-b <bssid>]
    Add/update saved network with provided params
    <ssid> - SSID of the network
    open|owe|wpa2|wpa3 - Security type of the network.
        - Use 'open' or 'owe' for networks with no passphrase
           - 'open' - Open networks (Most prevalent)
           - 'owe' - Enhanced open networks
        - Use 'wpa2' or 'wpa3' for networks with passphrase
           - 'wpa2' - WPA-2 PSK networks (Most prevalent)
           - 'wpa3' - WPA-3 PSK networks
    -m - Mark the network metered.
    -d - Mark the network autojoin disabled.
    -b <bssid> - Set specific BSSID.
  forget-network <networkId>
    Remove the network mentioned by <networkId>
        - Use list-networks to retrieve <networkId> for the network
  status
    Current wifi status
  set-verbose-logging enabled|disabled
    Set the verbose logging enabled or disabled
  add-suggestion <ssid> open|owe|wpa2|wpa3 [<passphrase>] [-u] [-m] [-s] [-d][-b <bssid>]
    Add a network suggestion with provided params
    Use 'network-suggestions-set-user-approved com.android.shell yes' to approve suggestions added via shell (Needs root access)
    <ssid> - SSID of the network
    open|owe|wpa2|wpa3 - Security type of the network.
        - Use 'open' or 'owe' for networks with no passphrase
           - 'open' - Open networks (Most prevalent)
           - 'owe' - Enhanced open networks
        - Use 'wpa2' or 'wpa3' for networks with passphrase
           - 'wpa2' - WPA-2 PSK networks (Most prevalent)
           - 'wpa3' - WPA-3 PSK networks
    -u - Mark the suggestion untrusted.
    -m - Mark the suggestion metered.
    -s - Share the suggestion with user.
    -d - Mark the suggestion autojoin disabled.
    -b <bssid> - Set specific BSSID.
  remove-suggestion <ssid>
    Remove a network suggestion with provided SSID of the network
  remove-all-suggestions
    Removes all suggestions added via shell
  list-suggestions
    Lists the suggested networks added via shell
  set-connected-score <score>
    Set connected wifi network score (to choose between LTE & Wifi for default route).
    This turns off the active connected scorer (default or external).
    Only works while connected to a wifi network. This score will stay in effect until you call reset-connected-score or the device disconnects from the current network.
    <score> - Integer score should be in the range of 0 - 60
  reset-connected-score
    Turns on the default connected scorer.
    Note: Will clear any external scorer set.
  start-softap <ssid> (open|wpa2) <passphrase> [-b 2|5|6|any]
    Start softap with provided params
    Note that the shell command doesn't activate internet tethering. In some devices, internet sharing is possible when Wi-Fi STA is also enabled and isassociated to another AP with internet access.
    <ssid> - SSID of the network
    open|wpa2 - Security type of the network.
        - Use 'open' for networks with no passphrase
        - Use 'wpa2' for networks with passphrase
    -b 2|5|6|any - select the preferred band.
        - Use '2' to select 2.4GHz band as the preferred band
        - Use '5' to select 5GHz band as the preferred band
        - Use '6' to select 6GHz band as the preferred band
        - Use 'any' to indicate no band preference
    Note: If the band option is not provided, 2.4GHz is the preferred band.
          The exact channel is auto-selected by FW unless overridden by force-softap-channel command
  stop-softap
    Stop softap (hotspot)
  set-ipreach-disconnect enabled|disabled
    Sets whether CMD_IP_REACHABILITY_LOST events should trigger disconnects.
  get-ipreach-disconnect
    Gets setting of CMD_IP_REACHABILITY_LOST events triggering disconnects.
  set-poll-rssi-interval-msecs <int>
    Sets the interval between RSSI polls to <int> milliseconds.
  get-poll-rssi-interval-msecs
    Gets current interval between RSSI polls, in milliseconds.
  force-hi-perf-mode enabled|disabled
    Sets whether hi-perf mode is forced or left for normal operation.
  force-low-latency-mode enabled|disabled
    Sets whether low latency mode is forced or left for normal operation.
  network-suggestions-set-user-approved <package name> yes|no
    Sets whether network suggestions from the app is approved or not.
  network-suggestions-has-user-approved <package name>
    Queries whether network suggestions from the app is approved or not.
  imsi-protection-exemption-set-user-approved-for-carrier <carrier id> yes|no
    Sets whether Imsi protection exemption for carrier is approved or not
  imsi-protection-exemption-has-user-approved-for-carrier <carrier id>
    Queries whether Imsi protection exemption for carrier is approved or not
  imsi-protection-exemption-clear-user-approved-for-carrier <carrier id>
    Clear the user choice on Imsi protection exemption for carrier
  network-requests-remove-user-approved-access-points <package name>
    Removes all user approved network requests for the app.
  clear-user-disabled-networks
    Clears the user disabled networks list.
  send-link-probe
    Manually triggers a link probe.
  force-softap-channel enabled <int> | disabled
    Sets whether soft AP channel is forced to <int> MHz
    or left for normal   operation.
  force-country-code enabled <two-letter code> | disabled
    Sets country code to <two-letter code> or left for normal value
  set-wifi-watchdog enabled|disabled
    Sets whether wifi watchdog should trigger recovery
  get-wifi-watchdog
    Gets setting of wifi watchdog trigger recovery.
  get-softap-supported-features
    Gets softap supported features. Will print 'wifi_softap_acs_supported'
    and/or 'wifi_softap_wpa3_sae_supported', each on a separate line.
  settings-reset
    Initiates wifi settings reset
  add-request <ssid> open|owe|wpa2|wpa3 [<passphrase>] [-b <bssid>]
    Add a network request with provided params
    Use 'network-requests-set-user-approved android yes' to pre-approve requests added via rooted shell (Not persisted)
    <ssid> - SSID of the network
    open|owe|wpa2|wpa3 - Security type of the network.
        - Use 'open' or 'owe' for networks with no passphrase
           - 'open' - Open networks (Most prevalent)
           - 'owe' - Enhanced open networks
        - Use 'wpa2' or 'wpa3' for networks with passphrase
           - 'wpa2' - WPA-2 PSK networks (Most prevalent)
           - 'wpa3' - WPA-3 PSK networks
    -b <bssid> - Set specific BSSID.
  remove-request <ssid>
    Remove a network request with provided SSID of the network
  remove-all-requests
    Removes all active requests added via shell
  list-requests
    Lists the requested networks added via shell
  network-requests-set-user-approved <package name> yes|no
    Sets whether network requests from the app is approved or not.
    Note: Only 1 such app can be approved from the shell at a time
  network-requests-has-user-approved <package name>
    Queries whether network requests from the app is approved or not.
    Note: This only returns whether the app was set via the 'network-requests-set-user-approved' shell command
  qca-list-ifaces
    Lists active STA/AP interfaces (could be bridge interfaces). Command to set bridge iface will only apply to the first internal iface
  qca-set-txpower <iface> <power in dBm>
    Sets max txpower in dBm, and <iface> is from 'qca-list-ifaces'
  qca-set-ani-level <iface> <auto|fixed> [<ofdmlvl>]
    Sets ani level, and <iface> is from 'qca-list-ifaces'
  qca-get-thermal-info <iface>
    Gets thermal info, and <iface> is from 'qca-list-ifaces'
  qca-dump-thermal-events
    Dump thermal events from driver/firmware after boot
  qca-set-congestion-report <iface> <enable|disable> [<threshold> [interval]]
    Sets congestion report, and <iface> is AP iface from 'qca-list-ifaces'
  qca-dump-congestion-events
    Dump congestion events from driver/firmware after boot

到了这里,关于Android 使用adb操作WiFi相关指令的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Android 13 设置自动进入wifi adb模式

    Android11之前 wifi adb 端口默认是 5555,adb connect ip即可完成adb 连接 Android13 上,wifi adb 端口默认是 随机的6位数,每次wifi adb 连接需要打开开发者模式里面的\\\"无线调试\\\", 并且最麻烦的是每次连接新的wifi,都需要重新打开开发者模式里面的\\\"无线调试\\\",会生成新的端口号,需要输

    2024年02月16日
    浏览(36)
  • Android(安卓) 无线ADB调试手机(WiFi 调试、蓝牙调试)

    1. 手机和电脑连接同一局域网(连同一个 WiFi、手机开热点电脑连接、电脑开热点手机连接) 2.手机打开USB调试模式 3. 查找你需要连接的Android(安卓)设备的ip (方式一)手机开热点电脑连接(手机分享蓝牙网络给电脑连接): 1)电脑打开cmd窗口(win+R) 输入: 2)在cmd里面输入:

    2024年02月09日
    浏览(67)
  • 高通Android系列随身WIFI强行开启adb,关闭商家远程控制

    目前市面上便宜的随身wifi大概分为高通、中芯微、MTK几家的SOC。大部分Android产品都关闭了adb或者开启的是user adb,没有root权限。下面说说高通系列如何强行开root adb,以及关闭部分机器远程控制功能。 如果机器默认未开启adb,就需要直接使用硬件方式进入9008进行备份和刷机,

    2024年02月07日
    浏览(38)
  • HBuilder X 运行至于Android设备,报错创建ADB反向代理失败,当前使用的adb不支持wifi真机运行,请更换其他版本adb进行真机运行

    HBuilder X 运行至真机以及模拟器的时候出现了如下错误提示。 故障排查步骤一 : 各种重启 HBuilder X 出现一些问题对我来说已经见怪不怪,很多情况下重启都可以解决。 故障排查步骤二 : 重装HBuilder 我把HBuilder卸载了,到官网重新下载了最新版然后重新安装。 故障排查步骤三 

    2024年04月13日
    浏览(46)
  • Wifi adb 操作步骤

    手机开起热点,电脑和车机连接手机,或者电脑开热点,车机连接电脑,车机和电脑连接同一个网络 因为需要先使用usb,后面切换到wifi usb 电脑win键+r 输入cmd回车,进入命令行模式 车机查看地址命令是ifconfig,电脑查看地址命令是ipconfig 假设 192.168.1.39是车机地址,192.168.1.

    2024年01月19日
    浏览(34)
  • Android Studio 使用WIFI连接手机进行无线调试

    这样就表明成功了。

    2024年02月03日
    浏览(64)
  • WiFi adb 使用

    WiFi adb 使用 - 知乎 (zhihu.com) 使用adb命令连接WiFi进行无线调试_百度知道 (baidu.com) adb connect 172.20.30.5:5555 ADB Shell - Android ADB Commands Manual db: error: failed to get feature set: no devices/emulators found add shell 出现 error: no devices/emulators found_dzqdzq的技术博客_51CTO博客

    2023年04月09日
    浏览(47)
  • Android Wifi开发——Wifi锁(十九)

            有的时候我们需要 APP 在手机后台运行,但是会遇到手机一旦息屏或者断网,APP 无法正常运行的情况,这是因为手机屏幕关闭之后,并且其他的应用程序没有在使用 Wifi 的时候,系统大概在两分钟之后,会关闭 Wifi,使得 Wifi 处于睡眠状态。而 Wifi 锁 就是 Android 锁

    2024年02月07日
    浏览(36)
  • Android WiFi Service启动-Android13

    Android WiFi基础概览 AOSP 文档 心主题 WiFi概览 编译生成对应的jar包: \\\"/apex/com.android.wifi/javalib/service-wifi.jar\\\" 相关WiFi服务: WifiService 、 WifiScanningService 、 RttService 、 WifiAwareService 、 WifiP2pService frameworks/base/services/java/com/android/server/SystemServer.java WifiInjector.java : WiFi依赖性注入器。

    2024年01月21日
    浏览(36)
  • Android WiFi 开启流程(基于Android S)

    本文介绍Android S上WiFi的Enable流程 WifiManager.setWifiEnabled(true) - WifiServiceImpl.enable(pkgName, true) - setWifiEnabledInternal(packageName, enable, callingUid, callingPid, isPrivileged) - mSettingsStore.handleWifiToggled(enable) - Settings.Global.putInt(cr, Settings.Global.WIFI_ON, state) mPersistWifiState = state 记下wifi状态 - mActiveMod

    2024年02月03日
    浏览(32)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包