Skip to content

Commit 80c4d44

Browse files
author
The android_world Authors
committed
Update A11yMethod wiring
PiperOrigin-RevId: 881378037
1 parent d9c569f commit 80c4d44

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

android_world/env/android_world_controller.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,12 @@ class AndroidWorldController(base_wrapper.BaseWrapper):
162162
def __init__(
163163
self,
164164
env: env_interface.AndroidEnvInterface,
165-
a11y_method: A11yMethod = A11yMethod.A11Y_FORWARDER_APP,
165+
a11y_method: A11yMethod | None = None,
166166
install_a11y_forwarding_app: bool = True,
167167
):
168168
self._original_env = env
169+
if a11y_method is None:
170+
a11y_method = A11yMethod.A11Y_FORWARDER_APP
169171
if a11y_method == A11yMethod.A11Y_FORWARDER_APP:
170172
self._env = apply_a11y_forwarder_app_wrapper(
171173
env, install_a11y_forwarding_app
@@ -201,6 +203,7 @@ def refresh_env(self):
201203
console_port=self.env._coordinator._simulator._config.emulator_launcher.emulator_console_port,
202204
adb_path=self.env._coordinator._simulator._config.adb_controller.adb_path,
203205
grpc_port=self.env._coordinator._simulator._config.emulator_launcher.grpc_port,
206+
a11y_method=self._a11y_method,
204207
).env
205208
# pylint: enable=protected-access
206209
# pytype: enable=attribute-error
@@ -308,6 +311,7 @@ def get_controller(
308311
console_port: int = 5554,
309312
adb_path: str = DEFAULT_ADB_PATH,
310313
grpc_port: int = 8554,
314+
a11y_method: A11yMethod | None = None,
311315
) -> AndroidWorldController:
312316
"""Creates a controller by connecting to an existing Android environment."""
313317

@@ -326,4 +330,4 @@ def get_controller(
326330
)
327331
android_env_instance = loader.load(config)
328332
logging.info('Setting up AndroidWorldController.')
329-
return AndroidWorldController(android_env_instance)
333+
return AndroidWorldController(android_env_instance, a11y_method=a11y_method)

android_world/env/env_launcher_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_get_env(
5656
),
5757
)
5858
)
59-
mock_controller.assert_called_with(mock_android_env)
59+
mock_controller.assert_called_with(mock_android_env, a11y_method=None)
6060
mock_async_android_env.assert_called_with(mock_controller.return_value)
6161

6262

0 commit comments

Comments
 (0)