feat: 添加 Windows 真实实现层
- 新增 _windows_impl.py,包含 14 个 Windows 实现类 - 支持网络、蓝牙、传感器、音频、剪贴板、电源、位置、通知、显示、UI自动化、摄像头、进程管理、Shell 等功能 - 更新 README.md 添加 Windows 支持说明 - 更新 setup.py 添加 Windows 专用依赖
This commit is contained in:
1 parent
97d8b277d5
commit
0f9b6fcc5d
3 files changed
+1424
-5
No files matched your search
@@ -47,10 +47,31 @@ Android-pyApi 将完整的 Android SDK API 翻译为纯 Python 实现,让你
|
|||||||
| Camera | OpenCV / V4L2 | 真实拍照 |
|
| Camera | OpenCV / V4L2 | 真实拍照 |
|
||||||
| UI 自动化 | `xdotool` | 真实点击、输入、按键 |
|
| UI 自动化 | `xdotool` | 真实点击、输入、按键 |
|
||||||
|
|
||||||
|
### Windows 真实实现
|
||||||
|
|
||||||
|
在 Windows 环境下,以下 API 使用真实系统调用而非存根:
|
||||||
|
|
||||||
|
| API | 实现方式 | 真实行为 |
|
||||||
|
|-----|---------|---------|
|
||||||
|
| ConnectivityManager | `ipconfig` + `netsh` + `socket` | 真实 IP、接口、DNS、网关、WiFi 信息 |
|
||||||
|
| LocationManager | IP 地理定位 | 真实经纬度、城市、ISP |
|
||||||
|
| SensorManager | `wmi` + `psutil` | 真实温度、CPU 频率、风扇转速 |
|
||||||
|
| AudioManager | `pycaw` / PowerShell | 真实音量控制、静音 |
|
||||||
|
| BluetoothAdapter | PowerShell Bluetooth cmdlets | 真实设备列表、配对状态 |
|
||||||
|
| ClipboardManager | `pyperclip` | 真实剪贴板读写 |
|
||||||
|
| PowerManager / BatteryManager | `psutil` | 真实 CPU、内存、电池状态 |
|
||||||
|
| NotificationManager | `win10toast` / PowerShell | 真实桌面通知 (Toast) |
|
||||||
|
| Activity / Display | `pyautogui` + `screeninfo` + `win32api` | 真实屏幕尺寸、截屏 |
|
||||||
|
| ActivityManager | `psutil` + `tasklist` | 真实进程列表 |
|
||||||
|
| Shell | `subprocess` + PowerShell | 真实命令执行 |
|
||||||
|
| Camera | OpenCV | 真实拍照 |
|
||||||
|
| UI 自动化 | `pyautogui` + `win32gui` | 真实点击、输入、按键、窗口操作 |
|
||||||
|
|
||||||
### 跨平台
|
### 跨平台
|
||||||
|
|
||||||
- **Linux** — 系统级 API 使用真实实现
|
- **Linux** — 系统级 API 使用真实实现 (`_linux_impl.py`)
|
||||||
- **macOS / Windows** — 系统级 API 使用存根(后续支持)
|
- **Windows** — 系统级 API 使用真实实现 (`_windows_impl.py`)
|
||||||
|
- **macOS** — 系统级 API 使用存根(后续支持)
|
||||||
- **API 形状** — 所有平台一致,方法签名完全对齐 Android SDK
|
- **API 形状** — 所有平台一致,方法签名完全对齐 Android SDK
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
@@ -68,11 +89,14 @@ export PYTHONPATH=/path/to/Android-pyApi:$PYTHONPATH
|
|||||||
### 可选依赖
|
### 可选依赖
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Python 库 (所有平台通用)
|
||||||
|
pip install psutil requests Pillow opencv-python numpy
|
||||||
|
|
||||||
# Linux 系统工具
|
# Linux 系统工具
|
||||||
sudo apt install xclip xdotool libnotify-bin alsa-utils bluez lm-sensors
|
sudo apt install xclip xdotool libnotify-bin alsa-utils bluez lm-sensors
|
||||||
|
|
||||||
# Python 库
|
# Windows 专用库 (推荐安装以启用完整功能)
|
||||||
pip install psutil requests Pillow opencv-python numpy
|
pip install pyautogui pyperclip screeninfo pywin32 wmi pycaw comtypes win10toast
|
||||||
```
|
```
|
||||||
|
|
||||||
## 快速开始
|
## 快速开始
|
||||||
@@ -116,6 +140,7 @@ print(loc) # 真实经纬度
|
|||||||
android_pyapi/
|
android_pyapi/
|
||||||
├── _core.py # Stub 基类、全局上下文
|
├── _core.py # Stub 基类、全局上下文
|
||||||
├── _linux_impl.py # Linux 真实实现层 (14个实现类)
|
├── _linux_impl.py # Linux 真实实现层 (14个实现类)
|
||||||
|
├── _windows_impl.py # Windows 真实实现层 (14个实现类)
|
||||||
├── __init__.py # 统一导出
|
├── __init__.py # 统一导出
|
||||||
├── android/ # 167 个 Android 模块
|
├── android/ # 167 个 Android 模块
|
||||||
│ ├── app.py # Activity, Service, Fragment, Notification
|
│ ├── app.py # Activity, Service, Fragment, Notification
|
||||||
@@ -173,7 +198,6 @@ Android-pyApi 不是 Android 模拟器。它不包含 ART 虚拟机、SurfaceFli
|
|||||||
欢迎贡献!特别需要:
|
欢迎贡献!特别需要:
|
||||||
|
|
||||||
- macOS 真实实现层 (`_macos_impl.py`)
|
- macOS 真实实现层 (`_macos_impl.py`)
|
||||||
- Windows 真实实现层 (`_windows_impl.py`)
|
|
||||||
- 更多 API 的真实行为实现
|
- 更多 API 的真实行为实现
|
||||||
- 测试用例
|
- 测试用例
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -22,6 +22,21 @@ setup(
|
|||||||
"opencv-python",
|
"opencv-python",
|
||||||
"numpy",
|
"numpy",
|
||||||
],
|
],
|
||||||
|
"windows": [
|
||||||
|
"psutil",
|
||||||
|
"requests",
|
||||||
|
"Pillow",
|
||||||
|
"opencv-python",
|
||||||
|
"numpy",
|
||||||
|
"pyautogui",
|
||||||
|
"pyperclip",
|
||||||
|
"screeninfo",
|
||||||
|
"pywin32",
|
||||||
|
"wmi",
|
||||||
|
"pycaw",
|
||||||
|
"comtypes",
|
||||||
|
"win10toast",
|
||||||
|
],
|
||||||
"dev": [
|
"dev": [
|
||||||
"pytest",
|
"pytest",
|
||||||
"pytest-cov",
|
"pytest-cov",
|
||||||
|
|||||||
Reference in new issue
Block a user