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.
|
||||
|
||||
Reference in new issue
Block a user