fix(connection): ADB outage clears only ADB-derived store fields — protocol push truth survives by TTL (F2)
This commit is contained in:
1 parent
b451638c65
commit
8462ad494c
3 files changed
+121
-21
No files matched your search
@@ -53,17 +53,20 @@ FIELD_IS_AVAILABLE = "is_available"
|
||||
FIELD_CURRENT_APP = "current_app"
|
||||
FIELD_VOLUME_INFO = "volume_info"
|
||||
|
||||
ALL_FIELDS = (
|
||||
FIELD_AWAKE,
|
||||
FIELD_SESSIONS,
|
||||
FIELD_AUDIO_PLAYBACK,
|
||||
FIELD_RUNNING_APPS,
|
||||
# ADB-derived fields (cleared when the ADB connection goes down — they are
|
||||
# regenerated by the watchdog); protocol pushes (IS_ON/IS_AVAILABLE/
|
||||
# CURRENT_APP/VOLUME_INFO) are device-reported truth and expire by TTL only,
|
||||
# so an ADB outage never clobbers them.
|
||||
ADB_FIELDS = (FIELD_AWAKE, FIELD_SESSIONS, FIELD_AUDIO_PLAYBACK, FIELD_RUNNING_APPS)
|
||||
PROTOCOL_FIELDS = (
|
||||
FIELD_IS_ON,
|
||||
FIELD_IS_AVAILABLE,
|
||||
FIELD_CURRENT_APP,
|
||||
FIELD_VOLUME_INFO,
|
||||
)
|
||||
|
||||
ALL_FIELDS = ADB_FIELDS + PROTOCOL_FIELDS
|
||||
|
||||
|
||||
def volume_tuple(info) -> tuple | None:
|
||||
"""Normalize the protocol's volume push to ``(level, max, muted)``.
|
||||
@@ -206,7 +209,14 @@ class ShieldConnectionManager:
|
||||
the constructor; the import stays local so this module remains
|
||||
importable where androidtvremote2 is not installed.
|
||||
"""
|
||||
import androidtvremote2
|
||||
try:
|
||||
import androidtvremote2
|
||||
except ImportError:
|
||||
_LOGGER.warning(
|
||||
"androidtvremote2 is not installed — the remote-protocol "
|
||||
"transport is disabled and the entry degrades to ADB-only."
|
||||
)
|
||||
return None
|
||||
|
||||
return androidtvremote2.AndroidTVRemote(
|
||||
client_name=client_name,
|
||||
@@ -547,7 +557,9 @@ class ShieldConnectionManager:
|
||||
await self._poller.disconnect()
|
||||
except Exception:
|
||||
_LOGGER.debug("disconnect during reconnect decision failed", exc_info=True)
|
||||
self.store.clear(*ALL_FIELDS)
|
||||
# Only ADB-derived fields expire here: protocol pushes are
|
||||
# device-reported truth and must survive an ADB outage (t11 F2).
|
||||
self.store.clear(*ADB_FIELDS)
|
||||
self._notify()
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in new issue
Block a user