feat: protocol key/launch command layer — RemoteKeyCode maps, C-LAUNCH app launch, ADB digit keyevent fallback, PlaybackIntent protocol path

This commit is contained in:
James Mackay committed 2026-10-08 09:41:45 +01:00
1 parent 906126b0da
commit 61aca9d413
4 files changed
+92 -1

No files matched your search

@@ -403,6 +403,44 @@ class ShieldConnectionManager:
return False
return await self._poller.bring_to_foreground(package)
# -- Protocol command delegation (Phase 2) --
async def send_protocol_key(self, key: str, direction: str = "SHORT") -> bool:
"""Send a remote-protocol key push (fast, non-blocking).
Returns False when the transport is down or the send raises — entities
then fall back to the ADB keyevent path.
"""
if self._protocol is None:
return False
try:
self._protocol.send_key_command(key, direction)
return True
except Exception as err:
_LOGGER.debug("Protocol key %s failed: %s", key, err)
return False
async def launch_app(self, app_link_or_app_id: str) -> bool:
"""Launch an app or URL over the protocol transport.
``send_launch_app_command`` auto-prefixes ``market://launch?id=`` for
bare package ids (C-LAUNCH); deep links pass through unchanged.
"""
if self._protocol is None:
return False
try:
self._protocol.send_launch_app_command(app_link_or_app_id)
return True
except Exception as err:
_LOGGER.debug("Protocol launch %s failed: %s", app_link_or_app_id, err)
return False
async def send_digit_key(self, digit: str) -> bool:
"""Channel digit via the ADB keyevent path (fallback for §7)."""
if not self.available:
return False
return await self._poller.send_digit_keyevent(digit)
# ── Lifecycle ──
async def async_start(self) -> None: