feat: add methods to close forward connections#196
Conversation
|
use forward_remove, forward_remove_all instead |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #196 +/- ##
==========================================
- Coverage 34.80% 34.71% -0.09%
==========================================
Files 17 17
Lines 2201 2212 +11
Branches 327 329 +2
==========================================
+ Hits 766 768 +2
- Misses 1390 1399 +9
Partials 45 45 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds methods to close individual and all forwarded connections for Android devices, implementing functionality equivalent to adb forward --remove and adb forward --remove-all commands.
- Added
forward_close()method to remove a specific forwarded connection by local address - Added
forward_close_all()method to remove all forwarded connections for a device - Updated README documentation with usage examples for the new methods and existing forward functionality
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| adbutils/_device_base.py | Implements forward_close() and forward_close_all() methods for managing forwarded connections |
| README.md | Updated documentation to include examples for forward/close operations and corrected the section description |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| def forward_close_all(self) -> None: | ||
| """Remove all forwarded network connections.""" | ||
| self.open_transport("killforward-all").close() |
There was a problem hiding this comment.
The forward_close_all method should use a context manager (with statement) for the connection cleanup, consistent with other methods in the codebase like forward_list, reverse, and reverse_list. This ensures proper resource cleanup even if an exception occurs.
| self.open_transport("killforward-all").close() | |
| with self.open_transport("killforward-all"): | |
| pass |
This pull request introduces two new methods for device objects to close forwarded connections
as currently there is no way to kill forwards aside from killing the whole adb server (
adb.server_kill()).There are two new methods:
forward_close: close an existing forward connectionforward_close_all: close all open forwarded connections (device, not whole server).Additionally, examples on how to forward connections and close them is added to the readme.