"""ADB media session reader for NVIDIA Shield. Thin wrapper around ha_adb_common.AdbClientBase — adds the Shield-specific `poll()` method that calls wake check + media session in sequence. Re-exports MediaSessionInfo and ensure_adb_key for existing importers. """ import logging from .ha_adb_common import AdbClientBase, ensure_adb_key as _ensure_adb_key from .ha_adb_common import MediaSessionInfo # noqa: F401 (re-export) _LOGGER = logging.getLogger(__name__) DOMAIN = "nvidia_shield" def ensure_adb_key(hass_config_dir: str) -> str: """Ensure an ADB key pair exists for the nvidia_shield integration.""" return _ensure_adb_key(hass_config_dir, DOMAIN) class AdbMediaSessionPoller(AdbClientBase): """ADB client for NVIDIA Shield — extends base with wake-state tracking.""" def __init__(self, host: str, port: int, key_path: str): super().__init__(host, port, key_path) async def poll(self, foreground_package: str | None = None) -> MediaSessionInfo | None: """Query the current media session. Returns parsed info or None. Args: foreground_package: The package name of the foreground app, used to prefer its media session over stale sessions from other apps. """ return await self.poll_media_sessions(foreground_package)