ADB Connection - Cloud Phone

Updated by MoreLogin

1、Enable ADB for Cloud Phone

def updateAdb():
requestPath = '/api/cloudphone/updateAdb'
data = {'ids': [156**********795], "enableAdb": 'true'}
headers = requestHeader()
headers['Content-Type'] ='application/json'
response = + requestPath, json=data, headers=headers)

2、Connect and use ADB

  • After enabling ADB, enter "ADB connect address" in the command prompt interface to connect to the target address. After successfully logging in with the connection code, you can start using ADB
  • Sample code:
# -*- coding: utf-8 -*-
import os
import time
import datetime
import requests
import json

def click(device, x, y):
os.system("adb -s {} shell input tap {} {}".format(device, int(x), int(y)))

def swipe(device, start_x, start_y, end_x, end_y, duration=100):
os.system("adb -s {} shell input swipe {} {} {} {} {}".format(device, int(start_x), int(start_y), int(end_x), int(end_y), duration))

def launche_app(device, activity):
os.system("adb -s {} shell am start -n {}".format(device, activity))

def input_text(device, text):
os.system(r'adb -s {} shell "input text \"{}\""'.format(device, text))

def input_keyevent(device, keycode):
os.system('adb -s {} shell input keyevent {}'.format(device, int(keycode)))

def screenShootAndSave(device, localfilepath):
now =
file_name = "screecap_{}.png".format(now.strftime('%Y%m%d_%H%M%S'))
os.system("adb -s {} shell screencap -p /sdcard/{}".format(device, file_name))
os.system("adb -s {} pull /sdcard/{} {}\{}".format(device, file_name, localfilepath, file_name))
os.system('adb -s {} shell rm /sdcard/{}'.format(device, file_name))

3、ADB commands

You can click the link below to view:

How did we do?