android-env 1.2.1__py3-none-any.whl → 1.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- android_env/__init__.py +1 -1
- android_env/components/__init__.py +1 -1
- android_env/components/a11y/__init__.py +15 -0
- android_env/components/a11y/a11y_events.py +118 -0
- android_env/components/a11y/a11y_events_test.py +173 -0
- android_env/components/a11y/a11y_forests.py +128 -0
- android_env/components/a11y/a11y_forests_test.py +237 -0
- android_env/components/a11y/a11y_servicer.py +199 -0
- android_env/components/a11y/a11y_servicer_test.py +224 -0
- android_env/components/action_fns.py +132 -0
- android_env/components/action_fns_test.py +227 -0
- android_env/components/action_type.py +26 -3
- android_env/components/adb_call_parser.py +239 -196
- android_env/components/adb_call_parser_test.py +179 -209
- android_env/components/adb_controller.py +90 -52
- android_env/components/adb_controller_test.py +187 -16
- android_env/components/adb_log_stream.py +17 -5
- android_env/components/adb_log_stream_test.py +17 -3
- android_env/components/app_screen_checker.py +17 -15
- android_env/components/app_screen_checker_test.py +7 -8
- android_env/components/config_classes.py +203 -0
- android_env/components/coordinator.py +102 -338
- android_env/components/coordinator_test.py +59 -199
- android_env/components/device_settings.py +174 -0
- android_env/components/device_settings_test.py +228 -0
- android_env/components/dumpsys_thread.py +3 -4
- android_env/components/dumpsys_thread_test.py +1 -1
- android_env/components/errors.py +52 -10
- android_env/components/errors_test.py +110 -0
- android_env/components/log_stream.py +7 -5
- android_env/components/log_stream_test.py +1 -1
- android_env/components/logcat_thread.py +9 -8
- android_env/components/logcat_thread_test.py +3 -4
- android_env/components/{utils.py → pixel_fns.py} +20 -20
- android_env/components/{utils_test.py → pixel_fns_test.py} +20 -15
- android_env/components/setup_step_interpreter.py +47 -39
- android_env/components/setup_step_interpreter_test.py +4 -4
- android_env/components/simulators/__init__.py +1 -1
- android_env/components/simulators/base_simulator.py +116 -44
- android_env/components/simulators/base_simulator_test.py +131 -9
- android_env/components/simulators/emulator/__init__.py +1 -1
- android_env/components/simulators/emulator/emulator_launcher.py +67 -77
- android_env/components/simulators/emulator/emulator_launcher_test.py +153 -49
- android_env/components/simulators/emulator/emulator_simulator.py +276 -95
- android_env/components/simulators/emulator/emulator_simulator_test.py +314 -89
- android_env/components/simulators/fake/__init__.py +1 -1
- android_env/components/simulators/fake/fake_simulator.py +17 -25
- android_env/components/simulators/fake/fake_simulator_test.py +29 -12
- android_env/components/specs.py +18 -28
- android_env/components/specs_test.py +1 -44
- android_env/components/task_manager.py +48 -48
- android_env/components/task_manager_test.py +71 -60
- android_env/env_interface.py +37 -23
- android_env/environment.py +83 -51
- android_env/environment_test.py +68 -29
- android_env/loader.py +57 -43
- android_env/loader_test.py +115 -35
- android_env/proto/__init__.py +1 -1
- android_env/proto/a11y/__init__.py +15 -0
- android_env/proto/a11y/a11y.proto +75 -0
- android_env/proto/a11y/a11y_pb2.py +54 -0
- android_env/proto/a11y/a11y_pb2.pyi +49 -0
- android_env/proto/a11y/a11y_pb2_grpc.py +202 -0
- android_env/proto/a11y/android_accessibility_action.proto +32 -0
- android_env/proto/a11y/android_accessibility_action_pb2.py +37 -0
- android_env/proto/a11y/android_accessibility_action_pb2.pyi +13 -0
- android_env/proto/a11y/android_accessibility_action_pb2_grpc.py +24 -0
- android_env/proto/a11y/android_accessibility_forest.proto +29 -0
- android_env/proto/a11y/android_accessibility_forest_pb2.py +38 -0
- android_env/proto/a11y/android_accessibility_forest_pb2.pyi +13 -0
- android_env/proto/a11y/android_accessibility_forest_pb2_grpc.py +24 -0
- android_env/proto/a11y/android_accessibility_node_info.proto +122 -0
- android_env/proto/a11y/android_accessibility_node_info_clickable_span.proto +49 -0
- android_env/proto/a11y/android_accessibility_node_info_clickable_span_pb2.py +39 -0
- android_env/proto/a11y/android_accessibility_node_info_clickable_span_pb2.pyi +28 -0
- android_env/proto/a11y/android_accessibility_node_info_clickable_span_pb2_grpc.py +24 -0
- android_env/proto/a11y/android_accessibility_node_info_pb2.py +42 -0
- android_env/proto/a11y/android_accessibility_node_info_pb2.pyi +75 -0
- android_env/proto/a11y/android_accessibility_node_info_pb2_grpc.py +24 -0
- android_env/proto/a11y/android_accessibility_tree.proto +29 -0
- android_env/proto/a11y/android_accessibility_tree_pb2.py +38 -0
- android_env/proto/a11y/android_accessibility_tree_pb2.pyi +13 -0
- android_env/proto/a11y/android_accessibility_tree_pb2_grpc.py +24 -0
- android_env/proto/a11y/android_accessibility_window_info.proto +84 -0
- android_env/proto/a11y/android_accessibility_window_info_pb2.py +41 -0
- android_env/proto/a11y/android_accessibility_window_info_pb2.pyi +48 -0
- android_env/proto/a11y/android_accessibility_window_info_pb2_grpc.py +24 -0
- android_env/proto/a11y/rect.proto +30 -0
- android_env/proto/a11y/rect_pb2.py +37 -0
- android_env/proto/a11y/rect_pb2.pyi +17 -0
- android_env/proto/a11y/rect_pb2_grpc.py +24 -0
- android_env/proto/adb.proto +17 -6
- android_env/proto/adb_pb2.py +120 -107
- android_env/proto/adb_pb2.pyi +396 -0
- android_env/proto/adb_pb2_grpc.py +20 -0
- android_env/proto/emulator_controller.proto +68 -63
- android_env/proto/emulator_controller_pb2.py +142 -131
- android_env/proto/emulator_controller_pb2.pyi +672 -0
- android_env/proto/emulator_controller_pb2_grpc.py +505 -142
- android_env/proto/snapshot.proto +169 -0
- android_env/proto/snapshot_pb2.py +47 -0
- android_env/proto/snapshot_pb2.pyi +117 -0
- android_env/proto/snapshot_pb2_grpc.py +24 -0
- android_env/proto/snapshot_service.proto +289 -0
- android_env/proto/snapshot_service_pb2.py +54 -0
- android_env/proto/snapshot_service_pb2.pyi +86 -0
- android_env/proto/snapshot_service_pb2_grpc.py +487 -0
- android_env/proto/state.proto +63 -0
- android_env/proto/state_pb2.py +63 -0
- android_env/proto/state_pb2.pyi +85 -0
- android_env/proto/state_pb2_grpc.py +24 -0
- android_env/proto/task.proto +5 -1
- android_env/proto/task_pb2.py +42 -31
- android_env/proto/task_pb2.pyi +160 -0
- android_env/proto/task_pb2_grpc.py +20 -0
- android_env/wrappers/__init__.py +1 -1
- android_env/wrappers/a11y_grpc_wrapper.py +500 -0
- android_env/wrappers/a11y_grpc_wrapper_test.py +849 -0
- android_env/wrappers/base_wrapper.py +34 -13
- android_env/wrappers/base_wrapper_test.py +22 -16
- android_env/wrappers/discrete_action_wrapper.py +18 -17
- android_env/wrappers/discrete_action_wrapper_test.py +4 -4
- android_env/wrappers/flat_interface_wrapper.py +5 -5
- android_env/wrappers/flat_interface_wrapper_test.py +7 -11
- android_env/wrappers/float_pixels_wrapper.py +9 -10
- android_env/wrappers/float_pixels_wrapper_test.py +3 -3
- android_env/wrappers/gym_wrapper.py +19 -13
- android_env/wrappers/gym_wrapper_test.py +3 -5
- android_env/wrappers/image_rescale_wrapper.py +18 -21
- android_env/wrappers/image_rescale_wrapper_test.py +25 -37
- android_env/wrappers/last_action_wrapper.py +16 -13
- android_env/wrappers/last_action_wrapper_test.py +44 -51
- android_env/wrappers/rate_limit_wrapper.py +6 -3
- android_env/wrappers/rate_limit_wrapper_test.py +22 -1
- android_env/wrappers/tap_action_wrapper.py +16 -17
- android_env/wrappers/tap_action_wrapper_test.py +51 -16
- {android_env-1.2.1.dist-info → android_env-1.2.3.dist-info}/METADATA +14 -18
- android_env-1.2.3.dist-info/RECORD +141 -0
- {android_env-1.2.1.dist-info → android_env-1.2.3.dist-info}/WHEEL +1 -1
- android_env/proto/raw_observation.proto +0 -39
- android_env/proto/raw_observation_pb2.py +0 -27
- android_env/proto/raw_observation_pb2_grpc.py +0 -4
- android_env-1.2.1.dist-info/RECORD +0 -81
- {android_env-1.2.1.dist-info → android_env-1.2.3.dist-info/licenses}/LICENSE +0 -0
- {android_env-1.2.1.dist-info → android_env-1.2.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,203 @@
|
|
1
|
+
# coding=utf-8
|
2
|
+
# Copyright 2024 DeepMind Technologies Limited.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
"""Dataclass definitions used for instantiating AndroidEnv components."""
|
17
|
+
|
18
|
+
import dataclasses
|
19
|
+
|
20
|
+
|
21
|
+
@dataclasses.dataclass
|
22
|
+
class AdbControllerConfig:
|
23
|
+
"""Settings for instatiating an `AdbController` instance."""
|
24
|
+
|
25
|
+
# Filesystem path to the `adb` binary.
|
26
|
+
# NOTE: This must be a full path and must not contain environment variables
|
27
|
+
# or user folder shorthands (e.g. `~/some/path/to/adb`) since they will not be
|
28
|
+
# expanded internally by AndroidEnv.
|
29
|
+
adb_path: str = '~/Android/Sdk/platform-tools/adb'
|
30
|
+
# Port for adb server.
|
31
|
+
adb_server_port: int = 5037
|
32
|
+
# Default timeout in seconds for internal commands.
|
33
|
+
default_timeout: float = 120.0
|
34
|
+
# Name of the device to communicate with.
|
35
|
+
device_name: str = ''
|
36
|
+
|
37
|
+
|
38
|
+
@dataclasses.dataclass
|
39
|
+
class DeviceSettingsConfig:
|
40
|
+
"""Config class for DeviceSettings."""
|
41
|
+
|
42
|
+
# Whether to show circles on the screen indicating touch position.
|
43
|
+
show_touches: bool = True
|
44
|
+
# Whether to show blue lines on the screen indicating touch position.
|
45
|
+
show_pointer_location: bool = True
|
46
|
+
# Whether or not to show the status (top) bar.
|
47
|
+
show_status_bar: bool = False
|
48
|
+
# Whether or not to show the navigation (bottom) bar.
|
49
|
+
show_navigation_bar: bool = False
|
50
|
+
|
51
|
+
|
52
|
+
@dataclasses.dataclass
|
53
|
+
class CoordinatorConfig:
|
54
|
+
"""Config class for Coordinator."""
|
55
|
+
|
56
|
+
# Number of virtual "fingers" of the agent.
|
57
|
+
num_fingers: int = 1
|
58
|
+
# Whether to enable keyboard key events.
|
59
|
+
enable_key_events: bool = False
|
60
|
+
# Time between periodic restarts in minutes. If > 0, will trigger
|
61
|
+
# a simulator restart at the beginning of the next episode once the time has
|
62
|
+
# been reached.
|
63
|
+
periodic_restart_time_min: float = 0.0
|
64
|
+
# General Android settings.
|
65
|
+
device_settings: DeviceSettingsConfig = dataclasses.field(
|
66
|
+
default_factory=DeviceSettingsConfig
|
67
|
+
)
|
68
|
+
|
69
|
+
|
70
|
+
@dataclasses.dataclass
|
71
|
+
class SimulatorConfig:
|
72
|
+
"""Base class for all simulator configs."""
|
73
|
+
|
74
|
+
# If true, the log stream of the simulator will be verbose.
|
75
|
+
verbose_logs: bool = False
|
76
|
+
# How often to (asynchronously) grab the screenshot from the simulator.
|
77
|
+
# If <= 0, stepping the environment blocks on fetching the screenshot (the
|
78
|
+
# environment is synchronous).
|
79
|
+
interaction_rate_sec: float = 0.0
|
80
|
+
|
81
|
+
|
82
|
+
@dataclasses.dataclass
|
83
|
+
class EmulatorLauncherConfig:
|
84
|
+
"""Config class for EmulatorLauncher."""
|
85
|
+
|
86
|
+
# NOTE: If `adb_port`, `emulator_console_port` and `grpc_port` are defined
|
87
|
+
# (i.e. not all equal to 0), it is assumed that the emulator they point to
|
88
|
+
# exists already and EmulatorLauncher will be skipped.
|
89
|
+
|
90
|
+
# Filesystem path to the `emulator` binary.
|
91
|
+
emulator_path: str = '~/Android/Sdk/emulator/emulator'
|
92
|
+
# Filesystem path to the Android SDK root.
|
93
|
+
android_sdk_root: str = '~/Android/Sdk'
|
94
|
+
# Name of the AVD.
|
95
|
+
avd_name: str = ''
|
96
|
+
# Local directory for AVDs.
|
97
|
+
android_avd_home: str = '~/.android/avd'
|
98
|
+
# Name of the snapshot to load.
|
99
|
+
snapshot_name: str = ''
|
100
|
+
# Path to the KVM device.
|
101
|
+
kvm_device: str = '/dev/kvm'
|
102
|
+
# Path to directory which will hold temporary files.
|
103
|
+
tmp_dir: str = '/tmp/android_env/simulator/'
|
104
|
+
# GPU mode override.
|
105
|
+
# Please see
|
106
|
+
# https://developer.android.com/studio/run/emulator-acceleration#accel-graphics.
|
107
|
+
gpu_mode: str = 'swangle_indirect' # Alternative: swiftshader_indirect, host
|
108
|
+
# Whether to run in headless mode (i.e. without a graphical window).
|
109
|
+
run_headless: bool = True
|
110
|
+
# Whether to restrict network access.
|
111
|
+
# If True, will disable networking on the device. This option is only
|
112
|
+
# available for emulator version > 31.3.9 (June 2022).
|
113
|
+
restrict_network: bool = False
|
114
|
+
# Whether to set `SHOW_PERF_STATS=1` when launching the emulator to display
|
115
|
+
# performance and memory statistics.
|
116
|
+
show_perf_stats: bool = False
|
117
|
+
|
118
|
+
# ADB port for the Android device.
|
119
|
+
adb_port: int = 0
|
120
|
+
# Port for telnet communication with the emulator.
|
121
|
+
emulator_console_port: int = 0
|
122
|
+
# Port for gRPC communication with the emulator.
|
123
|
+
grpc_port: int = 0
|
124
|
+
|
125
|
+
|
126
|
+
@dataclasses.dataclass
|
127
|
+
class EmulatorConfig(SimulatorConfig):
|
128
|
+
"""Config class for EmulatorSimulator."""
|
129
|
+
|
130
|
+
# Configuration for launching the Android Emulator.
|
131
|
+
emulator_launcher: EmulatorLauncherConfig = dataclasses.field(
|
132
|
+
default_factory=EmulatorLauncherConfig
|
133
|
+
)
|
134
|
+
# Configuration for talking to adb.
|
135
|
+
adb_controller: AdbControllerConfig = dataclasses.field(
|
136
|
+
default_factory=AdbControllerConfig
|
137
|
+
)
|
138
|
+
# Path to file which holds emulator logs. If not provided, it will be
|
139
|
+
# determined by the EmulatorLauncher.
|
140
|
+
logfile_path: str = ''
|
141
|
+
# The number of times to try launching the emulator before rebooting (reboot
|
142
|
+
# on the n+1-st try).
|
143
|
+
launch_n_times_without_reboot: int = 1
|
144
|
+
# The number of times to try launching the emulator before reinstalling
|
145
|
+
# (reinstall on the n+1-st try).
|
146
|
+
launch_n_times_without_reinstall: int = 2
|
147
|
+
|
148
|
+
|
149
|
+
@dataclasses.dataclass
|
150
|
+
class FakeSimulatorConfig(SimulatorConfig):
|
151
|
+
"""Config class for FakeSimulator."""
|
152
|
+
|
153
|
+
# The dimensions in pixels of the device screen (HxW).
|
154
|
+
screen_dimensions: tuple[int, int] = (0, 0)
|
155
|
+
|
156
|
+
|
157
|
+
@dataclasses.dataclass
|
158
|
+
class TaskManagerConfig:
|
159
|
+
"""Config class for TaskManager."""
|
160
|
+
|
161
|
+
# If max_bad_states episodes finish in a bad state in a row, restart
|
162
|
+
# the simulation.
|
163
|
+
max_bad_states: int = 3
|
164
|
+
# The frequency to check for the current activity and view hierarchy.
|
165
|
+
# The unit is raw observation (i.e. each call to AndroidEnv.step()).
|
166
|
+
dumpsys_check_frequency: int = 150
|
167
|
+
# The maximum number of tries for extracting the current activity before
|
168
|
+
# forcing the episode to restart.
|
169
|
+
max_failed_current_activity: int = 10
|
170
|
+
# The maximum number of extras elements to store. If this number is exceeded,
|
171
|
+
# elements are dropped in the order they were received.
|
172
|
+
extras_max_buffer_size: int = 100
|
173
|
+
|
174
|
+
|
175
|
+
@dataclasses.dataclass
|
176
|
+
class TaskConfig:
|
177
|
+
"""Base config class for loading tasks."""
|
178
|
+
|
179
|
+
# The directory for temporary task-related resources.
|
180
|
+
tmp_dir: str = ''
|
181
|
+
|
182
|
+
|
183
|
+
@dataclasses.dataclass
|
184
|
+
class FilesystemTaskConfig(TaskConfig):
|
185
|
+
"""Config for protobuf files stored in the local filesystem."""
|
186
|
+
|
187
|
+
# Filesystem path to `.binarypb` or `.textproto` protobuf Task.
|
188
|
+
path: str = ''
|
189
|
+
|
190
|
+
|
191
|
+
@dataclasses.dataclass
|
192
|
+
class AndroidEnvConfig:
|
193
|
+
"""Config class for AndroidEnv."""
|
194
|
+
|
195
|
+
# Configs for main components.
|
196
|
+
task: TaskConfig = dataclasses.field(default_factory=TaskConfig)
|
197
|
+
task_manager: TaskManagerConfig = dataclasses.field(
|
198
|
+
default_factory=TaskManagerConfig
|
199
|
+
)
|
200
|
+
coordinator: CoordinatorConfig = dataclasses.field(
|
201
|
+
default_factory=CoordinatorConfig
|
202
|
+
)
|
203
|
+
simulator: SimulatorConfig = dataclasses.field(default_factory=EmulatorConfig)
|