Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions android_world/env/android_world_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,20 @@ def get_controller(
) -> AndroidWorldController:
"""Creates a controller by connecting to an existing Android environment."""

emulator_launcher = config_classes.EmulatorLauncherConfig(
emulator_console_port=console_port,
adb_port=console_port + 1,
grpc_port=grpc_port,
)
if hasattr(emulator_launcher, 'connect_to_existing'):
setattr(emulator_launcher, 'connect_to_existing', True)

config = config_classes.AndroidEnvConfig(
task=config_classes.FilesystemTaskConfig(
path=_write_default_task_proto()
),
simulator=config_classes.EmulatorConfig(
emulator_launcher=config_classes.EmulatorLauncherConfig(
emulator_console_port=console_port,
adb_port=console_port + 1,
grpc_port=grpc_port,
),
emulator_launcher=emulator_launcher,
adb_controller=config_classes.AdbControllerConfig(adb_path=adb_path),
),
)
Expand Down
12 changes: 9 additions & 3 deletions android_world/env/env_launcher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,21 @@ def test_get_env(

env_launcher._get_env(5556, "some_adb_path", 8554)

expected_launcher_config = config_classes.EmulatorLauncherConfig(
emulator_console_port=5556,
adb_port=5557,
grpc_port=8554,
)
if hasattr(expected_launcher_config, "connect_to_existing"):
setattr(expected_launcher_config, "connect_to_existing", True)

mock_loader.assert_called_with(
config=config_classes.AndroidEnvConfig(
task=config_classes.FilesystemTaskConfig(
path=android_world_controller._TASK_PATH
),
simulator=config_classes.EmulatorConfig(
emulator_launcher=config_classes.EmulatorLauncherConfig(
emulator_console_port=5556, adb_port=5557, grpc_port=8554
),
emulator_launcher=expected_launcher_config,
adb_controller=config_classes.AdbControllerConfig(
adb_path="some_adb_path"
),
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

"""Setup file for AndroidWorld."""

import importlib.resources
import os

import pkg_resources
import setuptools
from setuptools.command import build_py

Expand All @@ -42,10 +42,10 @@ def finalize_options(self):
def run(self):
# Import grpc_tools here, after setuptools has installed setup_requires
# dependencies.
from grpc_tools import protoc # pylint: disable=g-import-not-at-top
from grpc_tools import protoc # pylint: disable=g-import-not-at-top # pytype: disable=import-error

grpc_protos_include = pkg_resources.resource_filename(
'grpc_tools', '_proto'
grpc_protos_include = str(
importlib.resources.files('grpc_tools').joinpath('_proto')
)

for proto_path in _PACKAGE_PROTOS:
Expand Down
Loading