📅  最后修改于: 2023-12-03 14:59:11.298000             🧑  作者: Mango
As a programmer, you may already know about ADB (Android Debug Bridge) - a versatile command-line tool that allows you to communicate with an Android device over USB, Ethernet or WiFi. By default, ADB is configured to work over USB, but you can easily switch to WiFi mode in case you don't have a USB cable or want to debug your app wirelessly.
Once you have set up ADB wireless mode on your device, you can connect to it using the "adb connect" command followed by the device's IP address (or hostname) and port number. This will establish a TCP/IP connection between your computer and device over WiFi and allow you to run various ADB commands, such as installing apps, debugging or testing.
However, when you are done with the wireless debugging session, you may want to disconnect from the device to free up resources and prevent unauthorized access. This is where the "adb wifi disconnect" command comes into play.
The "adb wifi disconnect" command is a part of the ADB toolset that lets you disconnect from an Android device that is currently connected over WiFi. It terminates the TCP/IP connection between your computer and device, and frees up the resources used by ADB over WiFi.
This command is useful when you want to switch to a different device or connection mode, or simply want to release the WiFi connection to the device for other purposes. It's also a good practice to disconnect from the device when you're done debugging to avoid unauthorized access or errors due to conflicting connections.
The syntax for using "adb wifi disconnect" is simple:
adb wifi disconnect
When you run this command from a terminal/command prompt window, it will disconnect from any device currently connected over WiFi. Note that this command does not require any additional arguments, IP addresses, or device IDs, unlike "adb connect".
Here's an example of how to disconnect from a device using "adb wifi disconnect":
$ adb wifi disconnect
disconnect from 192.168.1.100:5555
In this example, "192.168.1.100" is the IP address of the device that was previously connected over WiFi, and "5555" is the TCP port used for ADB communication over WiFi.
In conclusion, "adb wifi disconnect" is a simple and useful command for disconnecting from an Android device that is currently connected in wireless ADB mode. It's easy to use and helps you release the resources used by ADB over WiFi, prevent unauthorized access, or switch to a different device or connection mode. If you haven't tried it yet, give it a go and see how it can simplify your wireless debugging workflow.