diff --git a/custom_components/nvidia_shield/__init__.py b/custom_components/nvidia_shield/__init__.py index 469e84a..4bf8247 100644 --- a/custom_components/nvidia_shield/__init__.py +++ b/custom_components/nvidia_shield/__init__.py @@ -83,9 +83,12 @@ def _yaml_seed_blocks(domain_config) -> list[dict]: if not isinstance(block, dict): continue name = block.get("name") or DEFAULT_NAME + # t32 F4 (review rider): the seed honors the block's shape — a + # protocol-only block does NOT force ADB on; ADB comes only when the + # block carries an adb host (interactive cosmetics stay in the flow). seed = { "name": name, - CONF_ADB_ENABLED: True, + CONF_ADB_ENABLED: bool(block.get(CONF_ADB_HOST)), CONF_ADB_HOST: str(block.get(CONF_ADB_HOST) or ""), CONF_ADB_PORT: int(block.get(CONF_ADB_PORT) or DEFAULT_ADB_PORT), # protocol fields are prefill hints ONLY — pairing stays interactive diff --git a/custom_components/nvidia_shield/config_flow.py b/custom_components/nvidia_shield/config_flow.py index ea4c78b..f55a08d 100644 --- a/custom_components/nvidia_shield/config_flow.py +++ b/custom_components/nvidia_shield/config_flow.py @@ -519,10 +519,12 @@ class NvidiaShieldConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): await self.async_set_unique_id(seed_unique_id) self._abort_if_unique_id_configured() - # route into the standard user flow (single interactive visit) + # route into the standard user flow (single interactive visit); + # t32 F4: the prefill honors the block shape — ADB only when the + # block actually carries an adb host. self._user_data = { "name": name, - CONF_ADB_ENABLED: True, + CONF_ADB_ENABLED: bool(block.get(CONF_ADB_HOST)), CONF_ADB_HOST: block.get(CONF_ADB_HOST, ""), CONF_ADB_PORT: block.get(CONF_ADB_PORT, DEFAULT_ADB_PORT), # protocol prefill hints ONLY (pairing stays interactive) diff --git a/tests/test_standalone_setup.py b/tests/test_standalone_setup.py index 1d70176..bb7c0c0 100644 --- a/tests/test_standalone_setup.py +++ b/tests/test_standalone_setup.py @@ -885,6 +885,54 @@ class TestMacLessDiscoveryF2: assert len(sys.modules[__name__]._zc_holder.entries) == 1 +class TestSeedBlockShapeF4: + """t32 F4 (rider): protocol-only seed blocks don't force ADB on.""" + + def test_protocol_only_block_keeps_adb_off(self): + import conftest + import entity_stublib + + entity_stublib.install() + if "nsh.init" not in sys.modules: + conftest._load_module("nsh.init", conftest._SHIELD_DIR / "__init__.py") + init_module = sys.modules["nsh.init"] + + blocks = init_module._yaml_seed_blocks( + {"name": "Proto", "protocol_host": "shield.local"} + ) + + assert blocks[0]["adb_enabled"] is False + assert blocks[0]["adb_host"] == "" + + def test_adb_block_keeps_adb_on(self): + import conftest + import entity_stublib + + entity_stublib.install() + if "nsh.init" not in sys.modules: + conftest._load_module("nsh.init", conftest._SHIELD_DIR / "__init__.py") + init_module = sys.modules["nsh.init"] + + blocks = init_module._yaml_seed_blocks( + {"name": "Adb", "adb_host": "10.0.0.31"} + ) + + assert blocks[0]["adb_enabled"] is True + + async def test_protocol_only_import_prefills_adb_off(self): + module = _form_module() + flow = module.NvidiaShieldConfigFlow() + flow.hass = FakeHass("/tmp/nsh-f4") + flow._async_current_entries = lambda: [] + + result = await flow.async_step_import( + {"name": "Proto", "protocol_host": "shield.local"} + ) + + assert result["type"] == "form" + assert flow._user_data["adb_enabled"] is False + + class TestZeroconfDiscovery: """P4-1a: _androidtvremote2._tcp discovery → pre-filled user step."""