Skip to content

Commit beca304

Browse files
committed
feat: add Wi-Fi ADB connection helpers
1 parent f51ca15 commit beca304

6 files changed

Lines changed: 775 additions & 148 deletions

File tree

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Android Bloatware Remover
22

3-
Remove unwanted pre-installed apps from your Android phone without root access. Works with Samsung, Xiaomi, Oppo, Vivo, Realme, Tecno, and OnePlus devices.
3+
Remove unwanted pre-installed apps from your Android phone without root access. Works with Samsung, Xiaomi, Oppo, Vivo, Realme, Tecno, OnePlus, Huawei, Honor, Motorola, and Nothing devices.
44

55
## What it does
66

@@ -101,6 +101,14 @@ You'll get four options:
101101
3. **Manual mode** - Type a package name (`com.android.chrome`) or search by app name (`chrome`)
102102
4. **Batch mode** - Removes all known bloatware at once (be careful!)
103103

104+
### Connecting over Wi-Fi
105+
106+
- Start the tool with Wi-Fi prompts: `python main.py --wifi`
107+
- Provide everything non-interactively with `--wifi-endpoint`, `--wifi-pair`, and `--wifi-code`
108+
- Enable wireless debugging on a cabled device using `python main.py --enable-tcpip`
109+
110+
See [WIFI_ADB_GUIDE.md](WIFI_ADB_GUIDE.md) for a complete walk-through, pairing reminders, and troubleshooting tips.
111+
104112
## Safety features
105113

106114
- **Risk levels**: Apps marked as SAFE, CAUTION, or DANGEROUS

WIFI_ADB_GUIDE.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Wi-Fi ADB Guide
2+
3+
Use Wi-Fi debugging when a cable is unreliable or you want to keep the device untethered while removing apps. Follow the steps below from top to bottom.
4+
5+
## Prerequisites
6+
7+
- Android 11 or newer with Developer Options unlocked
8+
- Phone and computer on the same Wi-Fi network
9+
- USB cable for the first pairing (only needed once per network)
10+
- Android Platform Tools (adb) available on your computer or the packaged copy shipped with this project
11+
12+
## Enable Developer Options and Wi-Fi debugging
13+
14+
1. Connect the phone with USB and run `adb devices` once to confirm debugging is allowed. Accept the prompt on the device.
15+
2. Open **Settings → Developer options**.
16+
3. Turn on **Wireless debugging**. If the option is greyed out, toggle USB debugging off and on first.
17+
4. Tap **Wireless debugging → Pair device with pairing code**. Leave this screen open.
18+
19+
## Pair the device
20+
21+
1. Run the tool with the new Wi-Fi helpers:
22+
```powershell
23+
python main.py --wifi
24+
```
25+
The program prompts for the IP address and pairing code.
26+
2. Enter the pairing IP and port shown on the phone.
27+
3. Enter the six-digit pairing code. A confirmation message appears if pairing succeeds.
28+
29+
You can also provide everything up front:
30+
```powershell
31+
python main.py --wifi-endpoint 192.168.0.42:5555 --wifi-pair 192.168.0.42:38921 --wifi-code 123456
32+
```
33+
34+
## Reconnect later without a cable
35+
36+
Once paired, enable TCP/IP on the device whenever you plug in a cable:
37+
```powershell
38+
python main.py --enable-tcpip --tcpip-port 5555
39+
```
40+
41+
Then unplug the cable and connect over Wi-Fi:
42+
```powershell
43+
python main.py --wifi-endpoint 192.168.0.42:5555
44+
```
45+
46+
If you forgot the endpoint, run `adb devices -l` to list active wireless sessions.
47+
48+
## Troubleshooting
49+
50+
- **Device not found**: verify both devices share the same network, or disable VPNs and private DNS.
51+
- **Pairing fails immediately**: pairing codes expire after about thirty seconds; request a new one before retrying.
52+
- **Commands are slow**: keep the screen awake and close heavy network traffic apps; 5 GHz Wi-Fi is more stable than 2.4 GHz.
53+
- **Need to reset**: disable Wireless debugging in Developer Options, re-enable it, and pair again.
54+
55+
After a successful Wi-Fi connection you can follow the normal removal workflow. Test mode continues to work with the `--test` flag even when Wi-Fi debugging is active.

core/adb_utils.py

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
import zipfile
1212
from dataclasses import dataclass
1313
from pathlib import Path
14+
import re
1415
from typing import Iterable, List, Optional
1516

1617
DEFAULT_TIMEOUT = 15
18+
DEFAULT_TCPIP_PORT = 5555
1719

1820

1921
@dataclass
@@ -328,12 +330,124 @@ def find_authorized_device(
328330
"ADBError",
329331
"ADBNotFoundError",
330332
"DEFAULT_TIMEOUT",
333+
"DEFAULT_TCPIP_PORT",
331334
"DeviceSelectionError",
332335
"DeviceState",
336+
"activate_tcpip_mode",
337+
"connect_wifi_device",
338+
"disconnect_device",
333339
"find_authorized_device",
340+
"is_wifi_serial",
334341
"list_devices",
335342
"parse_devices_output",
343+
"pair_device",
336344
"resolve_adb_path",
337345
"run_command",
338346
"start_server",
339347
]
348+
349+
350+
WIFI_SERIAL_PATTERN = re.compile(r"^[\w.-]+:\d+$")
351+
352+
353+
def is_wifi_serial(serial: str) -> bool:
354+
"""Return True when the serial refers to a network-connected device."""
355+
356+
if not serial:
357+
return False
358+
if serial.startswith("emulator-"):
359+
return False
360+
return bool(WIFI_SERIAL_PATTERN.match(serial))
361+
362+
363+
def activate_tcpip_mode(
364+
adb_path: str,
365+
*,
366+
device_serial: Optional[str] = None,
367+
port: int = DEFAULT_TCPIP_PORT,
368+
timeout: int = DEFAULT_TIMEOUT,
369+
) -> None:
370+
"""Ask a connected device to listen for TCP/IP debugging connections."""
371+
372+
run_command(
373+
adb_path,
374+
["tcpip", str(port)],
375+
device_serial=device_serial,
376+
timeout=timeout,
377+
check=True,
378+
)
379+
380+
381+
def pair_device(
382+
adb_path: str,
383+
host_with_port: str,
384+
pairing_code: str,
385+
*,
386+
timeout: int = DEFAULT_TIMEOUT,
387+
) -> None:
388+
"""Pair with a device over Wi-Fi using the provided pairing code."""
389+
390+
result = run_command(
391+
adb_path,
392+
["pair", host_with_port, pairing_code],
393+
timeout=timeout,
394+
check=False,
395+
)
396+
397+
if result.returncode != 0:
398+
raise ADBCommandError(
399+
"Failed to pair with Wi-Fi device",
400+
returncode=result.returncode,
401+
stdout=result.stdout,
402+
stderr=result.stderr,
403+
)
404+
405+
406+
def connect_wifi_device(
407+
adb_path: str,
408+
host_with_port: str,
409+
*,
410+
timeout: int = DEFAULT_TIMEOUT,
411+
) -> DeviceState:
412+
"""Connect to a Wi-Fi adb endpoint and return the resulting device state."""
413+
414+
result = run_command(
415+
adb_path,
416+
["connect", host_with_port],
417+
timeout=timeout,
418+
check=False,
419+
)
420+
421+
if result.returncode != 0:
422+
raise ADBCommandError(
423+
"Failed to connect to Wi-Fi device",
424+
returncode=result.returncode,
425+
stdout=result.stdout,
426+
stderr=result.stderr,
427+
)
428+
429+
refreshed = list_devices(adb_path, timeout=timeout)
430+
for device in refreshed:
431+
if device.serial == host_with_port:
432+
return device
433+
434+
raise DeviceSelectionError(
435+
"Connected to Wi-Fi device but it did not appear in the device list",
436+
devices=refreshed,
437+
)
438+
439+
440+
def disconnect_device(
441+
adb_path: str,
442+
host_with_port: str,
443+
*,
444+
timeout: int = DEFAULT_TIMEOUT,
445+
) -> None:
446+
"""Disconnect a specific adb endpoint."""
447+
448+
run_command(
449+
adb_path,
450+
["disconnect", host_with_port],
451+
timeout=timeout,
452+
check=False,
453+
)

0 commit comments

Comments
 (0)