Updated on 2023-10-11 GMT+08:00

ADB (Intranet)

When you connect to a cloud phone through a private network, create an ECS in your VPC as the jump server for connecting to the cloud phone. If you do not customize the network when buying a cloud phone server, create a VPC peering connection between your existing VPC and the VPC where the cloud phone server is located, as shown in Figure 1. The ECS can run either the Windows or Linux. This topic uses the Windows as an example.

Figure 1 Using ADB to access a cloud phone over an Intranet

Constraints and Limitations

  • You cannot establish a peering connection between the VPC of a tenant who has not purchased a server with the VPC where a purchased server is located. For example, in Figure 1, the tenant VPC and the VPC where the server resides belong to account A. A VPC peering connection across accounts cannot be created.
  • The CIDR block of your VPC cannot overlap with 172.31.0.0/16 and 10.237.0.0/16. Otherwise, the VPC peering connection may be invalid.
  • If multiple VPC peering connections are established between your VPC and the VPC where the cloud phone server resides, only one of the peering connections is automatically accepted.

Prerequisites

  • The cloud phone must be in the Running state.
  • The inbound rules configured for your VPC allow traffic from the IP address and port of the cloud phone to be accessed.

    To obtain the IP address and port number of a cloud phone, go to its details page and obtain the server listening address in the Application Port area.

    Figure 2 Application Port
  • A Windows ECS is available in your VPC.
  • If you want to use an IPv6 address to connect to a dual-stack cloud phone, ensure that your environment, such as your ECS, supports IPv6 addresses.

Step 1: Create a VPC Peering Connection (Only When the Jump Server and the Cloud Phone Are in Different VPCs)

  1. Log in to the management console.
  2. On the Service List page, choose Compute > Cloud Phone Host.

    The CPH console is displayed.

  3. In the navigation pane on the left, choose Servers. In the upper part of the server list, click Configure Route.
  4. In the right pane, record the project ID, VPC ID, and CIDR Block that will be required for creating a VPC peering connection.
    Figure 3 Information collection
  5. If there is no Accepted peering connection available, click VPC console to create a VPC peering connection.

    The VPC Peering page is displayed.

    If a VPC peering connection in the Accepted state exists, perform the following operations to go to the VPC Peering page:

    1. Choose Service List > Network > Virtual Private Cloud.
    2. In the navigation pane on the left, click VPC Peering.
  6. In the upper right corner, click Create VPC Peering Connection.
  7. Set parameters as prompted. Set Account to Another account, Peer Project ID to the project ID recorded in 4, and Peer VPC ID to the VPC ID recorded in 4. Click OK.
    Figure 4 Create VPC Peering Connection
  8. Wait for about 5 minutes until the VPC peering connection state changes to Accepted.
  9. Add routes for the VPC peering connection. For details, see Step 3: Add Routes for the VPC Peering Connection. In some regions, you cannot visit the route table module directly from the navigation pane on the left of the network console. In this case, add routes for the VPC peering connection by referring to Step 3: Add Routes for the VPC Peering Connection.

    When adding a route, set Destination to the CIDR block recorded in 4. After the route is added, the two VPCs can communicate with each other.

  10. (Optional) If you want to forward all outbound traffic of all of your cloud phones to the created VPC peering connection, perform operations by referring to Configuring a Route.

Step 2 Access the Cloud Phone Through ADB

  1. Log in to the ECS.
  2. Download ADB from the local PC and upload it to the ECS.

    Visit https://developer.android.com/studio/releases/platform-tools, switch the language to English in the upper right corner, and choose Download SDK Platform-Tools for Windows.

    Figure 5 Downloading ADB

    In the displayed dialog box, select the I have read and agree with the above terms and conditions check box, and click DOWNLOAD ANDROID SDK PLATFORM-TOOLS FOR WINDOWS.

  3. Decompress the ADB installation package (for example, platform-tools_r29.0.5-windows.zip) to the specified directory (PATH) on the ECS.
  4. Go to the PATH\platform-tools directory.
  5. Run the following ADB command to access the cloud phone:

    adb connect Listening IP address of the server: Listening port number of the server

    To obtain the listening IP address and port number of the server, perform the following steps:

    1. On the Instances page, click the name of the target cloud phone.
    2. In the Application Port area, obtain the listening IP address of the cloud phone server.
      Figure 6 Application Port

    Take the information in Figure 6 as an example. Run the following ADB command:

    adb connect 172.31.248.213:4673

    If you select Automatically-assigned IPv6 address when purchasing a cloud phone server, the system will allocate an IPv4 address and an IPv6 address to both the cloud phone and the server, as shown in Figure 7. The listening ports of the cloud phone's IPv4 and IPv6 addresses are the same, so are the listening ports of the cloud phone server.

    To use the IPv6 address to connect to the cloud phone, run the following ADB command:

    adb connect [2409:8c85:80:32:cb7e:97e3:e424:1286]:4615

    (Make sure you use square brackets to enclose the IPv6 address.)

    Figure 7 Application Port
  6. Run the adb devices command to check whether the current port is connected.

    If information similar to the following is displayed, the connection is successful:

    List of devices attached
    172.31.248.213:4673  device
  7. Run other ADB commands to operate the cloud phone.