feat(const,config_flow): option-gated adb_command service switch (default off) + curated app directory consts + README service/security notes (P4-2)

This commit is contained in:
James Mackay committed 2026-10-08 11:07:28 +01:00
1 parent f4d750ff92
commit 4222027602
1 file changed
+21 -8
+21 -8
View File
@@ -13,6 +13,7 @@ from .adb_session import ensure_adb_key
from .connection import ShieldConnectionManager
from .const import (
ATTR_MEDIA_DAG_INPUT_MAP,
CONF_ADB_COMMAND_ENABLED,
CONF_ADB_ENABLED,
CONF_ADB_HOST,
CONF_ADB_PORT,
@@ -279,14 +280,22 @@ class NvidiaShieldConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
for entry in self._async_current_entries():
if getattr(entry, "unique_id", None) != mac:
continue
# Known device — update hosts on IP change (core pattern)
options = {
**entry.options,
CONF_PROTOCOL_HOST: host,
CONF_ADB_HOST: host,
}
if options != entry.options:
self.hass.config_entries.async_update_entry(entry, options=options)
# Known device — update hosts only on a real IP change
# (core androidtv_remote pattern, simplified): an explicitly
# configured host that moved to the discovery address.
protocol_host = entry.options.get(CONF_PROTOCOL_HOST, "")
adb_host = entry.options.get(CONF_ADB_HOST, "")
if (protocol_host and protocol_host != host) or (
adb_host and adb_host != host
):
self.hass.config_entries.async_update_entry(
entry,
options={
**entry.options,
CONF_PROTOCOL_HOST: host,
CONF_ADB_HOST: host,
},
)
self.hass.config_entries.async_schedule_reload(entry.entry_id)
return self.async_abort(reason="already_configured")
self._abort_if_unique_id_configured()
@@ -524,6 +533,10 @@ class NvidiaShieldOptionsFlow(config_entries.OptionsFlow):
recv_key = vol.Optional(CONF_RECEIVER_ENTITY, default=recv)
schema_dict[recv_key] = sel["receiver"]
# P4-2a: the raw adb_command service is opt-in (default off)
current_flag = self._options.get(CONF_ADB_COMMAND_ENABLED, False)
schema_dict[vol.Optional(CONF_ADB_COMMAND_ENABLED, default=current_flag)] = bool
# Receiver input — dropdown from DAG if receiver is set, text otherwise
current_input = self._options.get(CONF_RECEIVER_INPUT, "")
receiver = self._options.get(CONF_RECEIVER_ENTITY)