galaxy-s22-toolkit 0.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,250 @@
1
+ Metadata-Version: 2.5
2
+ Name: galaxy-s22-toolkit
3
+ Version: 0.4.0
4
+ Summary: ADB wrapper library for Samsung Galaxy phone diagnostics and management (S/Note/A, Android 10+)
5
+ Project-URL: Homepage, https://github.com/user/galaxy-s22-toolkit
6
+ Project-URL: Repository, https://github.com/user/galaxy-s22-toolkit
7
+ Project-URL: Issues, https://github.com/user/galaxy-s22-toolkit/issues
8
+ Author-email: Phone Toolkit <user@example.com>
9
+ License: MIT
10
+ Keywords: adb,android,diagnostics,galaxy,mobile,phone,samsung
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Classifier: Topic :: System :: Monitoring
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: asyncio
23
+ Provides-Extra: dev
24
+ Requires-Dist: mypy>=1.5.0; extra == 'dev'
25
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
26
+ Requires-Dist: pytest-mock>=3.11.0; extra == 'dev'
27
+ Requires-Dist: pytest>=7.4.0; extra == 'dev'
28
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
29
+ Requires-Dist: types-requests>=2.31.0; extra == 'dev'
30
+ Requires-Dist: windows-toasts>=1.3; (sys_platform == 'win32') and extra == 'dev'
31
+ Provides-Extra: notify
32
+ Requires-Dist: windows-toasts>=1.3; extra == 'notify'
33
+ Provides-Extra: test
34
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'test'
35
+ Requires-Dist: pytest-mock>=3.11.0; extra == 'test'
36
+ Requires-Dist: pytest>=7.4.0; extra == 'test'
37
+ Description-Content-Type: text/markdown
38
+
39
+ # Galaxy S22+ Phone Toolkit
40
+
41
+ A comprehensive Python ADB wrapper library for Samsung Galaxy S22+ (SM-S906B) diagnostics, monitoring, and management.
42
+
43
+ ## Features
44
+
45
+ - **Typed ADB Client** - Async/sync execution with retry logic and exponential backoff
46
+ - **Device Information** - Model, Android version, security patch, build fingerprint, CPU, memory
47
+ - **Battery Monitoring** - Level, health, temperature, voltage, charge cycles, charging status
48
+ - **Storage Analysis** - Partition usage, large file finder, app storage breakdown
49
+ - **Logcat Streaming** - Real-time filtering, crash/ANR detection, permission denial tracking
50
+ - **Network Diagnostics** - Wi-Fi/mobile status, DNS, gateway, internet connectivity, speed tests
51
+ - **Thermal Monitoring** - Zone temperatures, throttling detection, CPU/GPU thermal status
52
+ - **App Management** - List/install/uninstall, permissions, cache/data clearing, freeze/thaw
53
+ - **Screen Control** - Screenshots, screen recording, UI dumps, input simulation
54
+
55
+ ## Installation
56
+
57
+ ```bash
58
+ pip install -e ./phone-lib
59
+ ```
60
+
61
+ Or with development dependencies:
62
+
63
+ ```bash
64
+ pip install -e ./phone-lib[dev]
65
+ ```
66
+
67
+ ## Quick Start
68
+
69
+ ```python
70
+ from phone import create_client, DeviceModule, BatteryModule, StorageModule
71
+
72
+ # Create client (auto-detects Galaxy S22+ serial RFCTA0AEKZP)
73
+ client = create_client()
74
+
75
+ # Get device info
76
+ device = DeviceModule(client)
77
+ info = device.get_device_info()
78
+ print(f"{info.model} - Android {info.android_version} - Patch: {info.security_patch}")
79
+
80
+ # Get battery info
81
+ battery = BatteryModule(client)
82
+ bat = battery.get_battery_info()
83
+ print(f"Battery: {bat.level}% ({bat.health.value}) - {bat.temperature_c:.1f}°C")
84
+
85
+ # Get storage info
86
+ storage = StorageModule(client)
87
+ for part in storage.get_storage_info():
88
+ print(f"{part.mount_point}: {part.usage_percent:.1f}% used ({part.free_gb:.1f}GB free)")
89
+
90
+ # Stream logcat for crashes
91
+ logcat = LogcatModule(client)
92
+
93
+
94
+ def on_crash(entry):
95
+ print(f"CRASH: {entry.tag}: {entry.message}")
96
+
97
+
98
+ logcat.monitor_for_crashes(on_crash, package_name="com.example.app")
99
+ ```
100
+
101
+ ## Async Usage
102
+
103
+ ```python
104
+ import asyncio
105
+ from phone import create_client
106
+
107
+
108
+ async def main():
109
+ client = create_client()
110
+
111
+ # Async shell command
112
+ output = await client.shell_async("dumpsys battery")
113
+ print(output)
114
+
115
+ # Async execute
116
+ result = await client.execute_async("getprop", "ro.build.version.release")
117
+ print(f"Android: {result}")
118
+
119
+
120
+ asyncio.run(main())
121
+ ```
122
+
123
+ ## Modules
124
+
125
+ | Module | Class | Description |
126
+ |--------|-------|-------------|
127
+ | `adb` | `AdbClient` | Core ADB connection and command execution |
128
+ | `device` | `DeviceModule` | Device properties, CPU, memory info |
129
+ | `battery` | `BatteryModule` | Battery health, temperature, charge cycles |
130
+ | `storage` | `StorageModule` | Partition usage, large files, app storage |
131
+ | `logcat` | `LogcatModule` | Log streaming, crash/ANR detection |
132
+ | `network` | `NetworkModule` | Wi-Fi, mobile, DNS, connectivity |
133
+ | `thermal` | `ThermalModule` | Thermal zones, throttling status |
134
+ | `apps` | `AppsModule` | Package management, permissions |
135
+ | `screen` | `ScreenModule` | Screenshots, recording, UI dumps |
136
+ | `repair` | `RepairModule` | Approved repair actions with persistent JSONL history |
137
+ | `notify` | `DesktopNotifier` | Windows toast notifications with Approve/Deny buttons |
138
+ | `paths` | `confined_path` | Path confinement (resolve + fixed-root verification) |
139
+
140
+ ## Repair Actions
141
+
142
+ `phone.repair.RepairModule` provides ~20 audited repair actions (storage,
143
+ apps, network, logcat). Approval policy: actions flagged `auto_approve` or
144
+ matching the configured `auto_approve_risk_levels` run without prompting;
145
+ everything else requires an explicit approval (toast buttons or callback).
146
+ Every executed result is appended to a JSONL history file and reloaded on
147
+ the next run.
148
+
149
+ ```python
150
+ from phone.repair import RepairModule
151
+
152
+ repair = RepairModule(client, history_path="logs/repair_history.jsonl")
153
+ results = await repair.execute_multiple(["clear_app_caches", "flush_dns"])
154
+ ```
155
+
156
+ Actions that need root (e.g. tombstone/ANR cleanup) are flagged
157
+ `requires_root=True` and report an honest failure on unrooted devices
158
+ instead of a silent no-op. Network toggles always attempt re-enable so a
159
+ half-failed reset never leaves a radio off.
160
+
161
+ ## Desktop Notifications
162
+
163
+ ```python
164
+ from phone.notify import DesktopNotifier
165
+
166
+ notifier = DesktopNotifier(app_id="Galaxy S22+ Toolkit", dashboard_url="http://127.0.0.1:8081")
167
+ notifier.notify("Health check", "All checks passed")
168
+ approved = await notifier.request_approval_async(
169
+ "Repair: reset_wifi", "Toggles Wi-Fi off/on", timeout_s=120
170
+ )
171
+ ```
172
+
173
+ Requires the optional `notify` extra (`pip install galaxy-s22-toolkit[notify]`,
174
+ Windows only). Timeout counts as denial.
175
+
176
+ ## Path Confinement
177
+
178
+ ```python
179
+ from phone.paths import confined_path, PathEscapeError
180
+
181
+ target = confined_path(root_dir, user_supplied) # raises PathEscapeError
182
+ ```
183
+
184
+ Every file write in the library resolves its candidate against a fixed
185
+ root and rejects `..` segments outright.
186
+
187
+ ## Data Models
188
+
189
+ All modules return typed dataclasses with slots for performance:
190
+
191
+ ```python
192
+ from phone.models import BatteryInfo, StorageInfo, DeviceInfo, HealthReport
193
+
194
+ # Full health report
195
+ report = HealthReport(
196
+ device=device_info,
197
+ battery=battery_info,
198
+ storage=storage_list,
199
+ network=network_info,
200
+ thermal=thermal_info,
201
+ )
202
+ print(report.summary)
203
+ print(report.is_healthy)
204
+ ```
205
+
206
+ ## Requirements
207
+
208
+ - Python 3.10+
209
+ - Android SDK Platform Tools (adb in PATH or at default locations)
210
+ - Samsung Galaxy S22+ with USB debugging enabled
211
+ - Device authorized (RSA key accepted on phone)
212
+
213
+ ## ADB Path Detection
214
+
215
+ The client automatically searches for ADB at:
216
+ 1. `C:\Users\tbaltzakis\Android\Sdk\platform-tools\adb.exe` (Windows)
217
+ 2. `/mnt/c/Users/tbaltzakis/Android/Sdk/platform-tools/adb` (WSL)
218
+ 3. `~/Android/Sdk/platform-tools/adb` (Linux/macOS)
219
+ 4. `/c/Users/tbaltzakis/Android/Sdk/platform-tools/adb` (Git Bash)
220
+ 5. `adb` (system PATH)
221
+
222
+ ## Testing
223
+
224
+ ```bash
225
+ # Run unit tests (mocked ADB)
226
+ pytest tests/
227
+
228
+ # Run integration tests (requires physical device)
229
+ pytest tests/ -m device
230
+
231
+ # Run with coverage
232
+ pytest --cov=phone tests/
233
+ ```
234
+
235
+ ## Code Quality
236
+
237
+ ```bash
238
+ # Lint
239
+ ruff check .
240
+
241
+ # Format
242
+ ruff format .
243
+
244
+ # Type check
245
+ mypy src/phone
246
+ ```
247
+
248
+ ## License
249
+
250
+ MIT License
@@ -0,0 +1,22 @@
1
+ phone/__init__.py,sha256=9KWqxHpePGU7vxiE_TAf9zyko2f7Maj94lGSr13bJ90,2197
2
+ phone/adb.py,sha256=wuswRc-d4SZloNEBelWacupFYE0bXKDX0Xy-2-tlpEg,24768
3
+ phone/apps.py,sha256=qFqtw2P1dHGUxSSgOGvOWfOloSpRFKri_5RAROwP3g0,12649
4
+ phone/battery.py,sha256=KwATXoiFgip5xWvFgizXbZ1a8d2VW6Pi_jmE5KcC0dI,8050
5
+ phone/capabilities.py,sha256=OIPo_nISxvNGI-M9vQou27bSlR9vKMJ96zs8egHKVIs,7755
6
+ phone/device.py,sha256=nyPsZjL-abTq5gqq56j-Kt0p2NEK6QhN7NzqWpAO_1o,11555
7
+ phone/exceptions.py,sha256=z7BlO592x-N2Oax1PttsYSIUcyeVt8SuFvkMk1x5JlE,2925
8
+ phone/logcat.py,sha256=HAofLBzpRts3Pw9-HPFPtvusHRW-iMlahauXCsXGmG0,30875
9
+ phone/models.py,sha256=efTzxxYNMGtJ3dPklgo3unJsFRDL6Yfg0NNNe7XuZbY,13349
10
+ phone/network.py,sha256=CpzrCrdw_RG2qdOnevVss_dVTyYXMnlGFrg_dle2sZI,14297
11
+ phone/notify.py,sha256=MwmenFQUkP6X8ASrLVf9GdJaMpQLFzpfKtxu3hthpZk,5292
12
+ phone/paths.py,sha256=u1XrafH9n3_KnUGEP6gsXptO4jvFUdJqrZBxCz4Yf5k,1202
13
+ phone/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ phone/repair.py,sha256=wgj0it5txlOllbfheBda0DI-G0zimEhxtrtAGjy8bxk,42517
15
+ phone/root.py,sha256=CjqE7eBoC700rzLCZ749tKWLQRIOVJ5U-T90egyjO14,5336
16
+ phone/screen.py,sha256=rQ6L5TWSFTwf-3sN4aql2eE_BN9UxTZVoX3rKVJsj48,8952
17
+ phone/storage.py,sha256=go6ymORIsEZBPqIaFME-BfcqWnCeilMRxnbdGGJA0nc,7340
18
+ phone/termux.py,sha256=-m8OOLuqoT8Udn4i_a7Cme8yN-pYAGeMzgNgoz__OCg,11880
19
+ phone/thermal.py,sha256=o9ErYJ3Wt6_f4XM7gGsOQyIa7qU2UTYAL8hqx5O7gYA,9427
20
+ galaxy_s22_toolkit-0.4.0.dist-info/METADATA,sha256=gh6ZtDfBRjvJ2dZHD66yLETtI_ikr82K6v1AD8sjAKY,7949
21
+ galaxy_s22_toolkit-0.4.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
22
+ galaxy_s22_toolkit-0.4.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
phone/__init__.py ADDED
@@ -0,0 +1,106 @@
1
+ """Galaxy Phone Toolkit - Python ADB wrapper library (Samsung Galaxy S/Note/A)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .adb import AdbClient, create_client
6
+ from .apps import AppsModule
7
+ from .battery import BatteryModule
8
+ from .capabilities import DeviceProfile, describe_model, detect_profile
9
+ from .device import DeviceModule
10
+ from .exceptions import (
11
+ AdbConnectionError,
12
+ CommandFailedError,
13
+ DeviceNotFoundError,
14
+ DeviceUnauthorizedError,
15
+ FileTransferError,
16
+ ParseError,
17
+ PhoneError,
18
+ TimeoutError,
19
+ )
20
+ from .logcat import LogcatModule
21
+ from .models import (
22
+ AppInfo,
23
+ BatteryHealth,
24
+ BatteryInfo,
25
+ BatteryStatus,
26
+ CpuInfo,
27
+ DeviceInfo,
28
+ HealthReport,
29
+ LogEntry,
30
+ LogLevel,
31
+ MemoryInfo,
32
+ NetworkInfo,
33
+ RootInfo,
34
+ StorageInfo,
35
+ ThermalInfo,
36
+ ThermalStatus,
37
+ ThermalZone,
38
+ )
39
+ from .network import NetworkModule
40
+ from .root import RootModule
41
+ from .screen import ScreenModule
42
+ from .storage import StorageModule
43
+ from .termux import (
44
+ TermuxApiCommand,
45
+ TermuxBattery,
46
+ TermuxBootManager,
47
+ TermuxClient,
48
+ TermuxCpuInfo,
49
+ TermuxWifiInfo,
50
+ )
51
+ from .thermal import ThermalModule
52
+
53
+ __version__ = "0.4.0"
54
+ __author__ = "Phone Toolkit"
55
+
56
+ __all__ = [
57
+ # Core
58
+ "AdbClient",
59
+ "create_client",
60
+ # Exceptions
61
+ "PhoneError",
62
+ "DeviceNotFoundError",
63
+ "DeviceUnauthorizedError",
64
+ "CommandFailedError",
65
+ "AdbConnectionError",
66
+ "ParseError",
67
+ "TimeoutError",
68
+ "FileTransferError",
69
+ # Models
70
+ "DeviceInfo",
71
+ "BatteryInfo",
72
+ "BatteryHealth",
73
+ "BatteryStatus",
74
+ "StorageInfo",
75
+ "LogEntry",
76
+ "LogLevel",
77
+ "NetworkInfo",
78
+ "RootInfo",
79
+ "ThermalInfo",
80
+ "ThermalStatus",
81
+ "ThermalZone",
82
+ "AppInfo",
83
+ "CpuInfo",
84
+ "MemoryInfo",
85
+ "HealthReport",
86
+ # Modules
87
+ "DeviceModule",
88
+ "DeviceProfile",
89
+ "detect_profile",
90
+ "describe_model",
91
+ "BatteryModule",
92
+ "StorageModule",
93
+ "LogcatModule",
94
+ "NetworkModule",
95
+ "RootModule",
96
+ "ThermalModule",
97
+ "AppsModule",
98
+ "ScreenModule",
99
+ # Termux
100
+ "TermuxClient",
101
+ "TermuxBattery",
102
+ "TermuxWifiInfo",
103
+ "TermuxCpuInfo",
104
+ "TermuxApiCommand",
105
+ "TermuxBootManager",
106
+ ]