Use the adb connect command to connect multiple Android devices (WIFI way)

Connection Instructions and Steps

In addition to USB connection to Android terminal devices (the USB port on the PC side is limited, and WIFI is more convenient in some cases), it can also be connected by adb connectcommands using the TCP/IP protocol.

  1. Turn on the USB debugging function in the phone settings (some phones can also restrict whether to allow remote debugging, if this option exists, you need to turn it on together).
  2. Connect the mobile phone and PC to the same network (connect to the same WIFI).
  3. Connect the phone to the computer using USB.
  4. Use the adb devicescommand to check the device connection

$ adb devices
List of devices attached
 693298 ff device # Currently connected device 1 
693298 gg device # Currently connected device 2

  1. Use the adb tcpipcommand to specify the tcpip port of the mobile device on the computer side

$ adb -s 693298 ff tcpip 5555 
restarting in TCP mode port:  5555  # enable result

The 5555 port is the default port, and other ports can also be used. -s is the parameter for operating the specified device in [adb] -s 693298ff is specified to perform this operation on the 693298ff device. If only one device is connected, this parameter can be omitted.

  1. Disconnect the USB connection between the phone and the PC
  2. Use the adb connectcommand to connect the phone to the computer

$ adb connect  192.168 . 3.142 : 5555 
connected to 192.168 . 3.142 : 5555  # remote connection result

192.168.3.142 is the ip of your mobile phone after connecting to WIFI. Again, the mobile phone and the computer need to be in the same network environment (as long as the wired network is in a local area network)

  1. Use the adb devicescommand to check the device connection

$ adb devices
List of devices attached
 192.168 .3 .142 : 5555     device   # Remotely connected mobile phone 
693298 gg device # Mobile phone connected via usb

  1. When multiple devices need to be connected, the above operation can be repeated, but the port number needs to be slightly modified and cannot be repeated .

It should be noted that if a mobile phone is connected to the PC through USB and tcpip at the same time, adb devices will recognize 2 devices, but they are actually 2 connection methods of the same mobile phone.

  1. When the device connection is no longer needed, you can use the adb disconnectcommand to disconnect, for example:

$ adb disconnect 192.168.3.142:5555

Expand knowledge (adb common commands)

  1. Check the mobile device

$ adb devices

  1. Install the package, if you need to overwrite, you need to add parameters installlater-r

$ adb install packsge (package path)

  1. Retain data and cache files to install new packages

$ adb install -r packages (package path)

  1. Uninstall the package

$ adb uninstall  package (package path)

  1. Close the adb service

$ adb kill-server

  1. Start the adb service

$ adb start-server

  1. View all package names in the phone

$ adb shell pm list packages

  1. View all third-party package names in the phone

$ adb shell pm list packages -3

  1. Cut the frequency and save the file as xxx.png on the phone

$ adb shell /system/bin/screencap -p /sdcard/xxx.png

  1. Save the mobile phone xxx.png file to the D disk file

$ adb pull /sdcard/xx.png D:/xxx.png

  1. Import computer files into mobile phones

$ adb push D:/xxx.text /adcard/xxx.text

  1. Clear cache data

$ adb shell pm clear com.ablesky.ui.activity

  1. Start the program

$ adb shell am start -n com.ablesky.ui.activity/com.ablesky.activity.SplashActivity

  1. Forcibly stop running the program

$ adb shell am force-stop com.ablesky.simpleness.activity

  1. View the log

$ adb logcat

  1. Print the log to the computer

$ adb logcat > D:\log.txt

  1. View the PID corresponding to the occupied port

$ netstat -aon|findstr "5037"

  1. View the process corresponding to the port number

  1. Kill a process

$ taskkill /pid 2027 /f

  1. Specify APP to generate random events 100 times

$ adb shell monkey -p package name 100

  1. Specify APP to generate random events 100 times and send detailed activity information

$ adb shell monkey -p packagename -v -v 100

  1. Obtain mobile phone system information (CPU, manufacturer name, etc.)

$ adb shell "cat /system/build.prop | grep "product""

  1. Get the phone system version

$ adb shell getprop ro.build.version.release

  1. Get the api version of the mobile phone system

$ adb shell getprop ro.build.version.sdk

  1. Get the model of the mobile phone

$ adb -d shell getprop ro.product.model

  1. Get the name of the mobile phone manufacturer

$ adb -d shell getprop ro.product.brand

  1. There are two ways to obtain the serial number of the mobile phone

$ adb get-serialno
$ adb shell getprop ro.serialno

  1. There are three ways to obtain the IMEI of the mobile phone. Due to the limitations of the mobile phone and the system, there are slight differences.

$ adb shell dumpsys iphonesubinfo where Device ID is the IMEI number
$ adb shell getprop gsm.baseband.imei
$ service call iphonesubinfo 1  # In this way, you need to process the acquired information yourself

  1. Get the mac address of the mobile phone

$ adb shell cat /sys/class/net/wlan0/address

  1. Get mobile phone memory information

$ adb shell cat /proc/meminfo

  1. Obtain mobile phone storage information

$ adb shell df

  1. Obtain the internal storage information of the mobile phone

$ adb shell df /mnt/shell/emulated # Meizu phone 
$ adb shell df /data # Others

  1. Obtain sdcard storage information:

$ adb shell df /storage/sdcard

  1. Get mobile phone resolution

$ adb shell "dumpsys window | grep mUnrestrictedScreen"

  1. Obtain the physical density of the mobile phone

$ adb shell wm density

  1. View the package name of the specified apk

$ aapt dump badging + full path to package

  1. View all apk package names

$ adb shell pm list package -f

Leave a Comment

Your email address will not be published. Required fields are marked *