Skip to main content

Async ADB Client

Project description

async-adbc

Test-测试

ADBC是ADB Client的纯python异步实现,ADBC直接跟ADB Server通信不需要靠进程调用命令行来执行ADB命令。 有以下特性:

  1. 支持async/await和同步调用
  2. 封装了一些性能测试相关的方法,供性能采集工具使用
  3. service(服务)为单位封装命令方法,能够跟 adbandroid shell命令更加一致。

安装

pip install async-adbc

快速入门

使用ADBClient

ADBClient对应的是adb命令

note 当连接设备只有一个的时候,adb命令可以省略-s <serialno>,但是ADBClient不会包含这种默认设备的命令方法。因为async-adbc认为adbdevice应该职责分明不应有太多的潜规则。因此用户想要操作某个设备一定要使用Device对象下的方法,Device下的方法相当于是帮我们默认传递了-s <serialno>

from async_adbc import ADBClient

adbc = ADBClient() # 默认连接 127.0.0.1:5037 ,也就是本机的adb server
version = awaitadbc.version() # 对应 `adb version`
print(version)

# 获取Android设备对象,对应 `adb devices`
devices = adbc.devices()
for device in devices:
    print(device.serialno)

使用Device

Device对象是对Android设备的抽象,所有需要指定 -s <serialno> 的操作都被封装到 Device 类中。

from async_adbc import ADBClient

adbc = ADBClient()

# 获取Android设备对象,对应 `adb devices`
default_device = adbc.device() # 获取 `adb devices` 的第一个设备

product_model = await defualt_device.prop.get("ro.product.model")
print(product_model)

# `device.pm` 对应 `adb shell pm`
packages = await default_device.pm.list_packages()
print(packages)

# `device.shell` 对应 `adb shell`
ret = await default_device.shell("echo hello")
print(ret)

# 封装了 `fps` ,用来获取安卓游戏的帧率,方案参考了`solopi`
fps_stat = await default_device.fps.stat("PKG_NAME")
print(fps_stat)

# 封装了 `mem`,用来获取安卓设备的内存信息
mem_stat = await default_device.mem.stat("PKB_NAME")
print(mem_stat)

# 还有流量、温度等等工具的封装...

参考

  1. adb协议 https://github.com/kaluluosi/adbDocumentation/blob/master/README.zh-cn.md
  2. ppadb https://github.com/Swind/pure-python-adb

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

async_adbc-2.0.0rc3.tar.gz (3.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

async_adbc-2.0.0rc3-py3-none-any.whl (3.5 MB view details)

Uploaded Python 3

File details

Details for the file async_adbc-2.0.0rc3.tar.gz.

File metadata

  • Download URL: async_adbc-2.0.0rc3.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for async_adbc-2.0.0rc3.tar.gz
Algorithm Hash digest
SHA256 75202cc1cd5d21cd799cc7bd3aea5ac6e5162c7015c4f52ef20c3633c6ffa5f7
MD5 ea9b6a2ef08e5d211ae51d480f7ead22
BLAKE2b-256 84bc594e34364a6c8894daa1157557bbe386af3f4c42ba9d94f0a50df05a77c6

See more details on using hashes here.

File details

Details for the file async_adbc-2.0.0rc3-py3-none-any.whl.

File metadata

  • Download URL: async_adbc-2.0.0rc3-py3-none-any.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for async_adbc-2.0.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 b38b62525e0a7e5ee8242bb6435130639ee021089dd64e339fab4ffa27a8e824
MD5 96c0cd6af9acaa0a902d513c3727a2fd
BLAKE2b-256 c1fbe1a016617ed10521f5c6cec62c365eb3e2a94e39f32fc4909e5a4f1264af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page