Metadata-Version: 2.4
Name: wetest-usb-tethering
Version: 0.0.3
Summary: 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.
Author: wetest
Author-email: wetest@tencent.com
Requires-Python: >=3.8,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: adbutils (>=2.11.0,<3.0.0)
Requires-Dist: uiautomator2 (>=3.2.9,<4.0.0)
Description-Content-Type: text/markdown

# Wetest USB Tethering

**Wetest USB Tethering** 通过 [uiautomator2](https://github.com/openatx/uiautomator2) 提供的控件操作能力，开启 Android 设备的 USB 共享功能。

## 使用指南

[fastpusher 自动化测试使用说明](https://doc.weixin.qq.com/doc/w3_AOgAFQb5ACcCNaDbXSOCxTVK2Dt4k?scode=AJEAIQdfAAoZBaCq1qAXAA2AZiAG0)

### 安装

支持 Python 3.8 及以上版本

```bash
python -m pip install wetest-usb-tethering --upgrade --extra-index-url https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple
```

### 快速上手

```python
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](./examples) 目录

## 原理说明

### 项目架构

本项目主要包含以下几个核心模块：

```shell
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 获取
```

### 扩展支持

要支持新的设备品牌，只需：

1. 在 `devices/` 目录下创建新的设备类，继承 `BaseDevice`
2. 实现 `_toggle_usb_tethering_on` 方法，用于开启 USB 共享功能
3. 在 `device_factory.py` 中注册新的品牌映射关系

