Metadata-Version: 2.4
Name: phoneproxy
Version: 0.1.1
Summary: ADB + hotspot routing session library for Windows
Author: phoneproxy
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: build<2.0,>=1.2; extra == "dev"
Requires-Dist: pytest<9.0,>=8.3; extra == "dev"
Requires-Dist: twine<7.0,>=5.1; extra == "dev"

﻿# phoneproxy

`phoneproxy` is a Windows ADB + hotspot routing tool available as both:
- an importable Python package for other programs, and
- a CLI wrapper for manual operation.

## Requirements

- Windows 10/11
- Run in an elevated PowerShell/cmd window (Administrator), or have a reachable `sudopipe` server (`sudopipe ping` succeeds)
- ADB available via `ADB_PATH` or default `C:\Program Files\platform-tools\adb.exe`
- USB debugging enabled and device authorized
- Phone hotspot already ON before startup

## Configuration

Create `.env` from `.env.example`:

```dotenv
ADB_PATH=
LAN_ADAPTER_NAME=
HOTSPOT_SSID=
ADB_DEVICE_SERIAL=
SUDOPIPE_PATH=

TWINE_USERNAME=__token__
TWINE_PASSWORD=
TWINE_TEST_PASSWORD=
```

Notes:
- `LAN_ADAPTER_NAME` fallback defaults to `이더넷`, then `Ethernet`.
- `HOTSPOT_SSID` is optional. If empty, SSID is detected from `adb shell dumpsys tethering`.
- `SUDOPIPE_PATH` is optional. If empty, `phoneproxy` resolves `sudopipe` from `PATH`.
- Windows must already have a saved Wi-Fi profile matching the hotspot SSID.
- For non-elevated runs, `phoneproxy` checks `sudopipe ping` and uses SudoPipe for privileged route cmdlets when available.

## Install (package)

```powershell
pip install .
```

## Library Usage

```python
from phoneproxy import PhoneProxySession, runtime_config_from_env

config = runtime_config_from_env(verbose=True)
session = PhoneProxySession(config)

state = session.start()      # non-interactive start, returns immediately
session.reset_ip()          # callable at any time
session.disable_proxy()     # after start(): LTE/data OFF, restore LAN default route
session.enable_proxy()      # after start(): LTE/data ON, remove LAN default route
session.stop()               # idempotent, restores LAN routes
```

## CLI Usage

With local wrapper (existing workflow):

```powershell
.\run_phoneproxy.bat
```

Direct CLI after install:

```powershell
phoneproxy run            # interactive q/r/d/e mode
phoneproxy run --headless # no q/r, Ctrl+C to stop
phoneproxy start          # alias of headless run
phoneproxy reset-ip
```

## Publish Workflow

Use the hf-storage-style publishing script:

```powershell
.\publish.bat testpypi
.\publish.bat pypi
```

`publish.bat` will:
- read `TWINE_USERNAME`, `TWINE_PASSWORD`, `TWINE_TEST_PASSWORD` from `.env` (unless already set in shell),
- run unit tests,
- build wheel/sdist,
- run `twine check`,
- upload to TestPyPI or PyPI.


