feat(const): protocol config keys + ports; connection manager generates missing certs before protocol start
This commit is contained in:
1 parent
a4e7a285d4
commit
e37a3be75f
3 files changed
+26
-13
No files matched your search
@@ -228,7 +228,7 @@ class ShieldConnectionManager:
|
||||
keyfile=settings["keyfile"],
|
||||
)
|
||||
|
||||
def _start_protocol(self) -> None:
|
||||
async def _start_protocol(self) -> None:
|
||||
"""Spin up the protocol transport alongside the ADB watchdog.
|
||||
|
||||
One owner per transport: the library's own ``keep_reconnecting()``
|
||||
@@ -245,6 +245,12 @@ class ShieldConnectionManager:
|
||||
client = self._protocol
|
||||
if client is None:
|
||||
return
|
||||
# Real client: make sure local certificate material exists before it
|
||||
# connects (fails soft — pair flows can regenerate).
|
||||
generate_cert = getattr(client, "async_generate_cert_if_missing", None)
|
||||
if generate_cert is not None:
|
||||
with contextlib.suppress(Exception):
|
||||
await generate_cert()
|
||||
self._protocol_loop = asyncio.get_running_loop()
|
||||
client.add_is_on_updated_callback(self._on_is_on)
|
||||
client.add_is_available_updated_callback(self._on_is_available)
|
||||
@@ -408,7 +414,7 @@ class ShieldConnectionManager:
|
||||
"""
|
||||
self._stopping = False
|
||||
self._tasks.append(self._create_task(self._watchdog(), "shield_adb_watchdog"))
|
||||
self._start_protocol()
|
||||
await self._start_protocol()
|
||||
|
||||
async def async_stop(self) -> None:
|
||||
"""Cancel all manager tasks and close the socket.
|
||||
|
||||
@@ -22,6 +22,13 @@ CONF_ADB_STORE_APP_INFO = "adb_store_app_info"
|
||||
CONF_ADB_HOST = "adb_host"
|
||||
CONF_ADB_PORT = "adb_port"
|
||||
|
||||
# Remote-protocol transport (androidtvremote2) — Phase 2
|
||||
CONF_PROTOCOL_ENABLED = "protocol_enabled"
|
||||
CONF_PROTOCOL_HOST = "protocol_host"
|
||||
CONF_PAIRING_CODE = "pairing_code"
|
||||
DEFAULT_PROTOCOL_API_PORT = 6466
|
||||
DEFAULT_PROTOCOL_PAIR_PORT = 6467
|
||||
|
||||
ADB_POLL_INTERVAL = 10 # seconds
|
||||
ADB_RETRY_INTERVAL = 300 # seconds before retrying a failed ADB connection
|
||||
DEFAULT_ADB_PORT = 5555
|
||||
|
||||
Reference in new issue
Block a user