adb detailed tutorial (2) - open mobile phone developer mode, connect Android devices through adb

  • adb is a very important debugging tool for Android mobile terminals.
  • This article introduces how to enable the developer mode of the mobile phone and how to connect to the adb of the computer

(I have uploaded the adb installation package to the network disk. You can directly search the official account [Skills Required for Software Testing] or scroll to the bottom of the article, click on the official account card to scan the QR code, and go to Follow to receive.)

First, the working principle of adb

  • adb provides access to a Unix shell that can be used to run various commands on the device. It is a client-server program consisting of the following three components:
    • Client: used to send commands. The client runs on the development machine. You can invoke the client from the command line terminal by issuing the adb command. daemon
    • Daemon (adbd): Used to run commands on the device. The daemon runs as a background process on each device.
    • Server: Used to manage communication between clients and daemons. The server runs as a background process on the development machine.
  • The workflow of adb:
    1. When an adb client starts, it first checks to see if an adb server process is already running.
    2. If not, it starts the server process.
    3. After the server starts, it binds to the local TCP port 5037 and listens for commands issued by the adb client.
    4. The server establishes connections to all running devices. It looks for emulators by scanning odd-numbered ports between 5555 and 5585. Once the server discovers the adb daemon (adbd), it establishes a connection to the appropriate port.
    5. Once the server has established a connection to the devices, they can be accessed using the adb command.

2. Turn on the USB debugging mode of the mobile phone

(1) Turn on the mobile phone developer mode

  • The "USB Debugging" switch is located on the developer options page, but the developer option entry is hidden by default
  • Depending on the device, the location or name of the developer options interface may be different. But the method is the same.
  • First, enter the "Settings - About Phone" page
  • Secondly, find the version information of the device, or the Android version number, or the software version number
    (I don’t know which one it is, you can also click on each version information on the mobile phone page [wry smile], click multiple times quickly, if it is correct , there will be a prompt "Click * again to enable developer mode")
  • Then, click 7 times quickly, and you can see the prompt "Developer mode is enabled"
  • Finally, return to the "System Management" or Settings page, and you can see the "Developer Options", which are generally at the bottom of the page.
  • The following is an example of enabling developer options (using a VIVO phone):
    1. Go to "Settings>System Management>About Phone>Version Information" page
      insert image description here
    2. Click the "Software Version Number" 7 times, and you will see the prompt "Developer mode has been turned on".
      (Because this device has already turned on the developer mode, so after clicking, the prompt is "You are already in developer mode, no need to perform this operation")
      insert image description here
    3. Return to the system management page, slide to the bottom to see "Developer Options"
      insert image description here
  • The developer mode of the following brands corresponds to the open position:
equipment set up
Google Pixel Settings > About Phone > Build Number
Samsung Galaxy S8 and later Settings > About Phone > Software Information > Version Number
LG G6 and above Settings > About Phone > Software Information > Version Number
HTC U11 and above Settings > About > Software Information > More > Version Number or Settings > System > About Phone > Software Information > More > Version Number
OnePlus 5T and above Settings > About Phone > Build Number
Millet Settings > My Device > All Parameters > MIUI Version
vivo Settings>System Management>About Phone>Version Information>Software Version Number
Huawei Settings > About phone > Build number

(2) Turn on USB debugging

  • Enter the developer options and turn on the developer options switch
    insert image description here
  • Scroll down, find the USB debugging switch, and turn it on.
    insert image description here

3. Connect Android devices via adb

  • Here is how to connect the device to the computer via USB
  1. First connect the device via USB
  2. Make sure the developer options and USB debugging switches on your phone are turned on.
  3. After connecting to the computer, you can see the "Allow USB debugging" pop-up box on the device
    insert image description here
  4. For the convenience of debugging later, check "Allow this computer to be used for debugging" here, and click OK
  5. Open the computer command line, enter the command "adb devices -l", check the output, you can see whether the device is connected successfully
    insert image description here
    • In response to "adb devices -l", adb outputs the following status information for each device:
      • Serial number: adb creates a string that uniquely identifies the device by its port number. Here is an example serial number: emulator-5554
      • Status: The connection status of the device can be one of the following:
        • offline: The device is not connected to adb or is not responding.
        • device: The device is connected to the adb server. Note that this status does not mean that the Android system is fully booted and functional, as the system is still booting while the device is connected to adb. The device is typically in this operating state after the system has finished booting.
        • no device: No device is connected.
    • Note: If you add the -l option, the devices command will tell what the device is. This information makes it easy to distinguish between devices when multiple devices are connected.

—————————————————————————————————
I have uploaded the adb installation package to the official account of the same name of the blog I run [software testing essential skills]. The public will also upload test-related materials from time to time, and they can go to collect them if necessary.

If necessary, click on the QR code at the bottom of the article to get it~insert image description here

Guess you like

Origin blog.csdn.net/weixin_40883833/article/details/131258378