Enable and verify Android USB tethering via uiautomator2, with device detection and helpers to download files and extract tar archives over the tethered LAN—useful for transfer testing and automation.
Project description
Wetest USB Tethering
Wetest USB Tethering 通过 uiautomator2 提供的控件操作能力,开启 Android 设备的 USB 共享功能。
使用指南
安装
支持 Python 3.8 及以上版本
python -m pip install wetest-usb-tethering --upgrade --extra-index-url https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple
快速上手
from wetest.usbtethering import create_device
device = create_device()
assert device.is_connected()
device.enable_usb_tethering()
assert device.is_usb_tethering_enabled()
device_file_path = device.download_file(download_file, "/sdcard/" + download_file)
更多示例请参考 examples 目录
原理说明
项目架构
本项目主要包含以下几个核心模块:
src/wetest/usbtethering/
├── device_factory.py # 设备工厂,负责自动识别设备品牌并创建对应实例
├── uiautomator_manager.py # UIAutomator管理器,处理设备连接和冲突
└── devices/
├── base.py # 设备基类,定义开启 USB 共享功能的通用接口
└── honor.py # 荣耀设备开启 USB 共享功能的实现
└── oppo.py # Oppo 设备开启 USB 共享功能的实现
└── resources/
├── fastpusher_linux_x86_64 # fastpusher 工具,从 https://git.woa.com/CloudTesting/UDT/fastpusher/-/tags 获取
扩展支持
要支持新的设备品牌,只需:
- 在
devices/目录下创建新的设备类,继承BaseDevice - 实现
_toggle_usb_tethering_on方法,用于开启 USB 共享功能 - 在
device_factory.py中注册新的品牌映射关系
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wetest_usb_tethering-0.0.1-py3-none-any.whl.
File metadata
- Download URL: wetest_usb_tethering-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dae4a78cd0ed164d05380ea98ac42a6ec7c18f5b60e940711dcbcf0c38507246
|
|
| MD5 |
9b0605b309a5acd7297e028a5cc2b31e
|
|
| BLAKE2b-256 |
91e1fb285a124695a7d3bf988102f46eb34f3be9b93969a8b989d2ac6c8f8cfc
|