Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions desktop/backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ def setup_adb(self, port):
self.send_to_flutter({"type": "error", "message": f"ADB Error: {e}"})
return False

def cleanup_adb(self, port):
self.send_to_flutter({"type": "log", "message": "[*] Cleaning up ADB..."})
try:
subprocess.run(["adb", "forward", "--remove", f"tcp:{port}"],
check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except Exception as e:
# Don't send error to flutter, as it might not be connected
print(f"ADB cleanup error: {e}")

def _recv_exact(self, sock, n):
"""Receive exactly n bytes from socket"""
data = b''
Expand Down Expand Up @@ -346,6 +355,7 @@ def audio_stream_logic(self, device_name, port):
sock.close()
except: pass

self.cleanup_adb(port)
self.is_streaming = False
self.send_to_flutter({"type": "status", "payload": "stopped"})
self.send_to_flutter({"type": "volume", "value": 0.0})
Expand Down
Loading