fix: make ADB poll failures visible and stop stale-state cling; cancel tracked poll tasks on unload (B2, B5-prep); lint cleanups across daemon modules

This commit is contained in:
James Mackay committed 2026-10-08 07:45:45 +01:00
1 parent 359b96ef9c
commit d3afda0a25
7 files changed
+86 -45

No files matched your search

@@ -3,6 +3,7 @@
Subclasses add device-specific polling (media sessions, wake state, etc.).
"""
import contextlib
import logging
from .media_session import MediaSessionInfo, parse_all_media_sessions, parse_media_session
@@ -90,18 +91,15 @@ class AdbClientBase:
async def disconnect(self) -> None:
"""Disconnect from the device."""
if self._device:
try:
with contextlib.suppress(Exception):
await self._device.close()
except Exception:
pass
self._device = None
self._connected = False
async def shell(self, cmd: str) -> str | None:
"""Run a shell command, reconnecting if needed."""
if not self._connected or not self._device:
if not await self.connect():
return None
if (not self._connected or not self._device) and not await self.connect():
return None
try:
return await self._device.shell(cmd)
except Exception as err:
@@ -187,7 +185,7 @@ class AdbClientBase:
seen = set()
# System packages to exclude
_EXCLUDED = {
excluded = {
"com.android.systemui",
"com.android.tv.settings",
"com.nvidia.diagtools",
@@ -206,7 +204,7 @@ class AdbClientBase:
match = re.search(r"I=(\S+)/", stripped)
if match:
pkg = match.group(1)
if pkg not in seen and pkg not in _EXCLUDED and not pkg.startswith("."):
if pkg not in seen and pkg not in excluded and not pkg.startswith("."):
seen.add(pkg)
apps.append({"package": pkg})
@@ -33,7 +33,9 @@ class PlaybackIntent:
adb_command: str | None = None
@classmethod
def create(cls, target_state: str, command: str, prior_state: str | None = None) -> "PlaybackIntent":
def create(
cls, target_state: str, command: str, prior_state: str | None = None
) -> "PlaybackIntent":
return cls(
target_state=target_state,
command=command,