No project description provided
Project description
ADBC
ADBC是ADB Client的纯python异步实现,ADBC直接跟ADB Server通信不需要靠进程调用命令行来执行ADB命令。 有以下特性:
- 支持async/await和同步调用
- 封装了一些性能测试相关的方法,供性能采集工具使用
- 以
service(服务)
为单位封装命令方法,能够跟adb
和android shell
命令更加一致。
安装
pip install async-adbc
快速入门
使用ADBClient
ADBClient
对应的是adb
命令
note 当连接设备只有一个的时候,
adb
命令可以省略-s <serialno>
,但是ADBClient
不会包含这种默认设备的命令方法。因为async-adbc
认为adb
和device
应该职责分明不应有太多的潜规则。因此用户想要操作某个设备一定要使用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)
# 还有流量、温度等等工具的封装...
参考
Project details
Release history Release notifications | RSS feed
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-1.0.17.tar.gz
(3.4 MB
view details)
Built Distribution
File details
Details for the file async_adbc-1.0.17.tar.gz
.
File metadata
- Download URL: async_adbc-1.0.17.tar.gz
- Upload date:
- Size: 3.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1016-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee8015bed57a2e931104c734dbe52701a48f39cf7c322ffbebcb68cdbeca14f8 |
|
MD5 | 4b68190a1db1eb3e112e82434f167e5d |
|
BLAKE2b-256 | 17f0bec5d7877a170c024811dea077ef6919c811e66a9cf5f8c58a72affa85ce |
File details
Details for the file async_adbc-1.0.17-py3-none-any.whl
.
File metadata
- Download URL: async_adbc-1.0.17-py3-none-any.whl
- Upload date:
- Size: 3.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1016-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51759f590e0c825544574ced5a7b5a20263b3089aeb9c3da64a27b3d14bcd544 |
|
MD5 | 3ae02059d733c5154d807e0ba2aef9a0 |
|
BLAKE2b-256 | f7ff824d1b708b21d1783db98c35d28603936d7d5425384b57db7f81501b5225 |