Skip to content

Commit 8494b8d

Browse files
authored
Merge pull request #5 from PixelCode01/feature/wifi-adb-support
add Wi-Fi ADB connection helpers
2 parents 07c15f8 + 368bdbd commit 8494b8d

File tree

6 files changed

+531
-132
lines changed

6 files changed

+531
-132
lines changed

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

0 commit comments

Comments
 (0)