android-env 1.2.2__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.
Files changed (142) hide show
  1. android_env/__init__.py +1 -1
  2. android_env/components/__init__.py +1 -1
  3. android_env/components/a11y/__init__.py +15 -0
  4. android_env/components/a11y/a11y_events.py +118 -0
  5. android_env/components/a11y/a11y_events_test.py +173 -0
  6. android_env/components/a11y/a11y_forests.py +128 -0
  7. android_env/components/a11y/a11y_forests_test.py +237 -0
  8. android_env/components/a11y/a11y_servicer.py +199 -0
  9. android_env/components/a11y/a11y_servicer_test.py +224 -0
  10. android_env/components/action_fns.py +132 -0
  11. android_env/components/action_fns_test.py +227 -0
  12. android_env/components/action_type.py +26 -3
  13. android_env/components/adb_call_parser.py +233 -185
  14. android_env/components/adb_call_parser_test.py +165 -163
  15. android_env/components/adb_controller.py +19 -28
  16. android_env/components/adb_controller_test.py +100 -9
  17. android_env/components/adb_log_stream.py +3 -3
  18. android_env/components/adb_log_stream_test.py +1 -1
  19. android_env/components/app_screen_checker.py +15 -13
  20. android_env/components/app_screen_checker_test.py +1 -1
  21. android_env/components/config_classes.py +203 -0
  22. android_env/components/coordinator.py +53 -338
  23. android_env/components/coordinator_test.py +26 -283
  24. android_env/components/device_settings.py +174 -0
  25. android_env/components/device_settings_test.py +228 -0
  26. android_env/components/dumpsys_thread.py +3 -4
  27. android_env/components/dumpsys_thread_test.py +1 -1
  28. android_env/components/errors.py +2 -5
  29. android_env/components/errors_test.py +1 -1
  30. android_env/components/log_stream.py +2 -2
  31. android_env/components/log_stream_test.py +1 -1
  32. android_env/components/logcat_thread.py +9 -8
  33. android_env/components/logcat_thread_test.py +2 -3
  34. android_env/components/{utils.py → pixel_fns.py} +19 -20
  35. android_env/components/{utils_test.py → pixel_fns_test.py} +20 -15
  36. android_env/components/setup_step_interpreter.py +45 -37
  37. android_env/components/setup_step_interpreter_test.py +1 -1
  38. android_env/components/simulators/__init__.py +1 -1
  39. android_env/components/simulators/base_simulator.py +79 -23
  40. android_env/components/simulators/base_simulator_test.py +131 -9
  41. android_env/components/simulators/emulator/__init__.py +1 -1
  42. android_env/components/simulators/emulator/emulator_launcher.py +62 -81
  43. android_env/components/simulators/emulator/emulator_launcher_test.py +120 -43
  44. android_env/components/simulators/emulator/emulator_simulator.py +111 -98
  45. android_env/components/simulators/emulator/emulator_simulator_test.py +174 -138
  46. android_env/components/simulators/fake/__init__.py +1 -1
  47. android_env/components/simulators/fake/fake_simulator.py +9 -17
  48. android_env/components/simulators/fake/fake_simulator_test.py +23 -8
  49. android_env/components/specs.py +1 -1
  50. android_env/components/specs_test.py +1 -1
  51. android_env/components/task_manager.py +26 -31
  52. android_env/components/task_manager_test.py +1 -18
  53. android_env/env_interface.py +1 -17
  54. android_env/environment.py +27 -17
  55. android_env/environment_test.py +51 -25
  56. android_env/loader.py +57 -43
  57. android_env/loader_test.py +115 -35
  58. android_env/proto/__init__.py +1 -1
  59. android_env/proto/a11y/__init__.py +15 -0
  60. android_env/proto/a11y/a11y.proto +75 -0
  61. android_env/proto/a11y/a11y_pb2.py +54 -0
  62. android_env/proto/a11y/a11y_pb2.pyi +49 -0
  63. android_env/proto/a11y/a11y_pb2_grpc.py +202 -0
  64. android_env/proto/a11y/android_accessibility_action.proto +32 -0
  65. android_env/proto/a11y/android_accessibility_action_pb2.py +37 -0
  66. android_env/proto/a11y/android_accessibility_action_pb2.pyi +13 -0
  67. android_env/proto/a11y/android_accessibility_action_pb2_grpc.py +24 -0
  68. android_env/proto/a11y/android_accessibility_forest.proto +29 -0
  69. android_env/proto/a11y/android_accessibility_forest_pb2.py +38 -0
  70. android_env/proto/a11y/android_accessibility_forest_pb2.pyi +13 -0
  71. android_env/proto/a11y/android_accessibility_forest_pb2_grpc.py +24 -0
  72. android_env/proto/a11y/android_accessibility_node_info.proto +122 -0
  73. android_env/proto/a11y/android_accessibility_node_info_clickable_span.proto +49 -0
  74. android_env/proto/a11y/android_accessibility_node_info_clickable_span_pb2.py +39 -0
  75. android_env/proto/a11y/android_accessibility_node_info_clickable_span_pb2.pyi +28 -0
  76. android_env/proto/a11y/android_accessibility_node_info_clickable_span_pb2_grpc.py +24 -0
  77. android_env/proto/a11y/android_accessibility_node_info_pb2.py +42 -0
  78. android_env/proto/a11y/android_accessibility_node_info_pb2.pyi +75 -0
  79. android_env/proto/a11y/android_accessibility_node_info_pb2_grpc.py +24 -0
  80. android_env/proto/a11y/android_accessibility_tree.proto +29 -0
  81. android_env/proto/a11y/android_accessibility_tree_pb2.py +38 -0
  82. android_env/proto/a11y/android_accessibility_tree_pb2.pyi +13 -0
  83. android_env/proto/a11y/android_accessibility_tree_pb2_grpc.py +24 -0
  84. android_env/proto/a11y/android_accessibility_window_info.proto +84 -0
  85. android_env/proto/a11y/android_accessibility_window_info_pb2.py +41 -0
  86. android_env/proto/a11y/android_accessibility_window_info_pb2.pyi +48 -0
  87. android_env/proto/a11y/android_accessibility_window_info_pb2_grpc.py +24 -0
  88. android_env/proto/a11y/rect.proto +30 -0
  89. android_env/proto/a11y/rect_pb2.py +37 -0
  90. android_env/proto/a11y/rect_pb2.pyi +17 -0
  91. android_env/proto/a11y/rect_pb2_grpc.py +24 -0
  92. android_env/proto/adb.proto +13 -1
  93. android_env/proto/adb_pb2.py +120 -107
  94. android_env/proto/adb_pb2.pyi +396 -0
  95. android_env/proto/adb_pb2_grpc.py +20 -0
  96. android_env/proto/emulator_controller.proto +1 -1
  97. android_env/proto/emulator_controller_pb2.py +142 -131
  98. android_env/proto/emulator_controller_pb2.pyi +672 -0
  99. android_env/proto/emulator_controller_pb2_grpc.py +497 -136
  100. android_env/proto/snapshot.proto +1 -1
  101. android_env/proto/snapshot_pb2.py +30 -19
  102. android_env/proto/snapshot_pb2.pyi +117 -0
  103. android_env/proto/snapshot_pb2_grpc.py +20 -0
  104. android_env/proto/snapshot_service.proto +1 -1
  105. android_env/proto/snapshot_service_pb2.py +36 -25
  106. android_env/proto/snapshot_service_pb2.pyi +86 -0
  107. android_env/proto/snapshot_service_pb2_grpc.py +119 -28
  108. android_env/proto/state.proto +1 -1
  109. android_env/proto/state_pb2.py +46 -35
  110. android_env/proto/state_pb2.pyi +85 -0
  111. android_env/proto/state_pb2_grpc.py +20 -0
  112. android_env/proto/task.proto +4 -1
  113. android_env/proto/task_pb2.py +41 -30
  114. android_env/proto/task_pb2.pyi +160 -0
  115. android_env/proto/task_pb2_grpc.py +20 -0
  116. android_env/wrappers/__init__.py +1 -1
  117. android_env/wrappers/a11y_grpc_wrapper.py +500 -0
  118. android_env/wrappers/a11y_grpc_wrapper_test.py +849 -0
  119. android_env/wrappers/base_wrapper.py +1 -5
  120. android_env/wrappers/base_wrapper_test.py +1 -7
  121. android_env/wrappers/discrete_action_wrapper.py +15 -14
  122. android_env/wrappers/discrete_action_wrapper_test.py +1 -1
  123. android_env/wrappers/flat_interface_wrapper.py +5 -5
  124. android_env/wrappers/flat_interface_wrapper_test.py +1 -1
  125. android_env/wrappers/float_pixels_wrapper.py +5 -4
  126. android_env/wrappers/float_pixels_wrapper_test.py +1 -1
  127. android_env/wrappers/gym_wrapper.py +1 -1
  128. android_env/wrappers/gym_wrapper_test.py +1 -1
  129. android_env/wrappers/image_rescale_wrapper.py +13 -10
  130. android_env/wrappers/image_rescale_wrapper_test.py +1 -1
  131. android_env/wrappers/last_action_wrapper.py +5 -4
  132. android_env/wrappers/last_action_wrapper_test.py +1 -1
  133. android_env/wrappers/rate_limit_wrapper.py +1 -1
  134. android_env/wrappers/rate_limit_wrapper_test.py +1 -1
  135. android_env/wrappers/tap_action_wrapper.py +12 -12
  136. android_env/wrappers/tap_action_wrapper_test.py +49 -14
  137. {android_env-1.2.2.dist-info → android_env-1.2.3.dist-info}/METADATA +14 -16
  138. android_env-1.2.3.dist-info/RECORD +141 -0
  139. {android_env-1.2.2.dist-info → android_env-1.2.3.dist-info}/WHEEL +1 -1
  140. android_env-1.2.2.dist-info/RECORD +0 -88
  141. {android_env-1.2.2.dist-info → android_env-1.2.3.dist-info/licenses}/LICENSE +0 -0
  142. {android_env-1.2.2.dist-info → android_env-1.2.3.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
1
1
  # coding=utf-8
2
- # Copyright 2023 DeepMind Technologies Limited.
2
+ # Copyright 2024 DeepMind Technologies Limited.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -20,11 +20,14 @@ import os
20
20
  from unittest import mock
21
21
 
22
22
  from absl.testing import absltest
23
- from android_env import environment
23
+ from android_env import env_interface
24
24
  from android_env import loader
25
+ from android_env.components import config_classes
25
26
  from android_env.components import coordinator as coordinator_lib
27
+ from android_env.components import device_settings as device_settings_lib
26
28
  from android_env.components import task_manager as task_manager_lib
27
29
  from android_env.components.simulators.emulator import emulator_simulator
30
+ from android_env.components.simulators.fake import fake_simulator
28
31
  from android_env.proto import task_pb2
29
32
 
30
33
 
@@ -32,49 +35,116 @@ class LoaderTest(absltest.TestCase):
32
35
 
33
36
  @mock.patch.object(task_manager_lib, 'TaskManager', autospec=True)
34
37
  @mock.patch.object(emulator_simulator, 'EmulatorSimulator', autospec=True)
38
+ @mock.patch.object(device_settings_lib, 'DeviceSettings', autospec=True)
35
39
  @mock.patch.object(coordinator_lib, 'Coordinator', autospec=True)
36
40
  @mock.patch.object(builtins, 'open', autospec=True)
37
- def test_load(self, mock_open, coordinator, simulator, task_manager):
38
-
41
+ def test_load_emulator(
42
+ self,
43
+ mock_open,
44
+ mock_coordinator,
45
+ mock_device_settings,
46
+ mock_simulator_class,
47
+ mock_task_manager,
48
+ ):
49
+
50
+ # Arrange.
39
51
  mock_open.return_value.__enter__ = mock_open
40
52
  mock_open.return_value.read.return_value = ''
53
+ config = config_classes.AndroidEnvConfig(
54
+ task=config_classes.FilesystemTaskConfig(path='some/path/'),
55
+ simulator=config_classes.EmulatorConfig(
56
+ emulator_launcher=config_classes.EmulatorLauncherConfig(
57
+ avd_name='my_avd',
58
+ android_avd_home='~/.android/avd',
59
+ android_sdk_root='~/Android/Sdk',
60
+ emulator_path='~/Android/Sdk/emulator/emulator',
61
+ run_headless=False,
62
+ ),
63
+ adb_controller=config_classes.AdbControllerConfig(
64
+ adb_path='~/Android/Sdk/platform-tools/adb',
65
+ ),
66
+ ),
67
+ )
41
68
 
42
- env = loader.load(
43
- task_path='some/path/',
44
- avd_name='my_avd',
45
- android_avd_home='~/.android/avd',
46
- android_sdk_root='~/Android/Sdk',
47
- emulator_path='~/Android/Sdk/emulator/emulator',
48
- adb_path='~/Android/Sdk/platform-tools/adb',
49
- run_headless=False,
69
+ # Act.
70
+ env = loader.load(config)
71
+
72
+ # Assert.
73
+ self.assertIsInstance(env, env_interface.AndroidEnvInterface)
74
+ mock_simulator_class.assert_called_with(
75
+ config=config_classes.EmulatorConfig(
76
+ emulator_launcher=config_classes.EmulatorLauncherConfig(
77
+ avd_name='my_avd',
78
+ android_avd_home=os.path.expanduser('~/.android/avd'),
79
+ android_sdk_root=os.path.expanduser('~/Android/Sdk'),
80
+ emulator_path=os.path.expanduser(
81
+ '~/Android/Sdk/emulator/emulator'
82
+ ),
83
+ run_headless=False,
84
+ gpu_mode='swangle_indirect',
85
+ ),
86
+ adb_controller=config_classes.AdbControllerConfig(
87
+ adb_path=os.path.expanduser('~/Android/Sdk/platform-tools/adb'),
88
+ adb_server_port=5037,
89
+ ),
90
+ )
91
+ )
92
+ mock_coordinator.assert_called_with(
93
+ mock_simulator_class.return_value,
94
+ mock_task_manager.return_value,
95
+ mock_device_settings.return_value,
50
96
  )
51
97
 
52
- self.assertIsInstance(env, environment.AndroidEnv)
53
- simulator.assert_called_with(
54
- adb_controller_args=dict(
55
- adb_path=os.path.expanduser('~/Android/Sdk/platform-tools/adb'),
56
- adb_server_port=5037,
98
+ @mock.patch.object(task_manager_lib, 'TaskManager', autospec=True)
99
+ @mock.patch.object(fake_simulator, 'FakeSimulator', autospec=True)
100
+ @mock.patch.object(device_settings_lib, 'DeviceSettings', autospec=True)
101
+ @mock.patch.object(coordinator_lib, 'Coordinator', autospec=True)
102
+ @mock.patch.object(builtins, 'open', autospec=True)
103
+ def test_load_fake_simulator(
104
+ self,
105
+ mock_open,
106
+ mock_coordinator,
107
+ mock_device_settings,
108
+ mock_simulator_class,
109
+ mock_task_manager,
110
+ ):
111
+
112
+ # Arrange.
113
+ mock_open.return_value.__enter__ = mock_open
114
+ mock_open.return_value.read.return_value = ''
115
+ config = config_classes.AndroidEnvConfig(
116
+ task=config_classes.FilesystemTaskConfig(path='some/path/'),
117
+ simulator=config_classes.FakeSimulatorConfig(
118
+ screen_dimensions=(1234, 5678)
57
119
  ),
58
- emulator_launcher_args=dict(
59
- avd_name='my_avd',
60
- android_avd_home=os.path.expanduser('~/.android/avd'),
61
- android_sdk_root=os.path.expanduser('~/Android/Sdk'),
62
- emulator_path=os.path.expanduser('~/Android/Sdk/emulator/emulator'),
63
- run_headless=False,
64
- gpu_mode='swiftshader_indirect'),
65
120
  )
66
- coordinator.assert_called_with(
67
- simulator.return_value,
68
- task_manager.return_value,
121
+
122
+ # Act.
123
+ env = loader.load(config)
124
+
125
+ # Assert.
126
+ self.assertIsInstance(env, env_interface.AndroidEnvInterface)
127
+ mock_simulator_class.assert_called_with(
128
+ config=config_classes.FakeSimulatorConfig(
129
+ screen_dimensions=(1234, 5678)
130
+ )
131
+ )
132
+ mock_coordinator.assert_called_with(
133
+ mock_simulator_class.return_value,
134
+ mock_task_manager.return_value,
135
+ mock_device_settings.return_value,
69
136
  )
70
137
 
71
138
  @mock.patch.object(task_manager_lib, 'TaskManager', autospec=True)
72
139
  @mock.patch.object(emulator_simulator, 'EmulatorSimulator', autospec=True)
73
140
  @mock.patch.object(coordinator_lib, 'Coordinator', autospec=True)
74
141
  @mock.patch.object(builtins, 'open', autospec=True)
75
- def test_task(self, mock_open, coordinator, simulator, task_manager):
142
+ def test_task(
143
+ self, mock_open, mock_coordinator, mock_simulator, mock_task_manager
144
+ ):
76
145
 
77
- del coordinator, simulator
146
+ # Arrange.
147
+ del mock_coordinator, mock_simulator
78
148
  mock_open.return_value.__enter__ = mock_open
79
149
  mock_open.return_value.read.return_value = r'''
80
150
  id: "fake_task"
@@ -82,20 +152,30 @@ name: "Fake Task"
82
152
  description: "Task for testing loader."
83
153
  max_episode_sec: 0
84
154
  '''
85
-
86
- env = loader.load(
87
- task_path='some/path/',
88
- avd_name='my_avd',
155
+ config = config_classes.AndroidEnvConfig(
156
+ task=config_classes.FilesystemTaskConfig(path='some/path/'),
157
+ simulator=config_classes.EmulatorConfig(
158
+ emulator_launcher=config_classes.EmulatorLauncherConfig(
159
+ avd_name='my_avd'
160
+ ),
161
+ adb_controller=config_classes.AdbControllerConfig(
162
+ adb_path='~/Android/Sdk/platform-tools/adb',
163
+ ),
164
+ ),
89
165
  )
90
166
 
167
+ # Act.
168
+ env = loader.load(config)
169
+
170
+ # Assert.
91
171
  expected_task = task_pb2.Task()
92
172
  expected_task.id = 'fake_task'
93
173
  expected_task.name = 'Fake Task'
94
174
  expected_task.description = 'Task for testing loader.'
95
175
  expected_task.max_episode_sec = 0
96
176
 
97
- task_manager.assert_called_with(expected_task)
98
- assert isinstance(env, environment.AndroidEnv)
177
+ mock_task_manager.assert_called_with(expected_task)
178
+ self.assertIsInstance(env, env_interface.AndroidEnvInterface)
99
179
 
100
180
 
101
181
  if __name__ == '__main__':
@@ -1,5 +1,5 @@
1
1
  # coding=utf-8
2
- # Copyright 2023 DeepMind Technologies Limited.
2
+ # Copyright 2024 DeepMind Technologies Limited.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -0,0 +1,15 @@
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
+
@@ -0,0 +1,75 @@
1
+ // Copyright 2024 DeepMind Technologies Limited.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ syntax = "proto3";
16
+
17
+ package android_env;
18
+
19
+ import "android_env/proto/a11y/android_accessibility_forest.proto";
20
+
21
+ option java_multiple_files = true;
22
+ option java_package = "com.google.androidenv.accessibilityforwarder";
23
+
24
+ // A service to send Accessibility information to a remote server.
25
+ //
26
+ // The client is assumed to be running inside an Android device (e.g. emulator
27
+ // or real device) while the server is assumed to be running outside (e.g. in a
28
+ // Python process).
29
+ service A11yService {
30
+ // Sends a forest of Accessibility trees to a server.
31
+ rpc SendForest(AndroidAccessibilityForest) returns (ForestResponse) {}
32
+ // Sends an a11y event to a server.
33
+ rpc SendEvent(EventRequest) returns (EventResponse) {}
34
+
35
+ // Long-lived bidirection communication between the client and the server.
36
+ rpc Bidi(stream ClientToServer) returns (stream ServerToClient) {}
37
+ }
38
+
39
+ // TODO(b/334952387): Remove `ForestResponse`, `EventRequest` and
40
+ // `EventResponse` once bidi communication is in-place.
41
+ message ForestResponse {
42
+ // The error if anything.
43
+ string error = 1;
44
+ }
45
+
46
+ // An Accessibility event.
47
+ message EventRequest {
48
+ // A single event as a dictionary.
49
+ map<string, string> event = 1;
50
+ }
51
+
52
+ message EventResponse {
53
+ // The error if anything.
54
+ string error = 1;
55
+ }
56
+
57
+ // The message sent from the Android device to the server running outside of the
58
+ // device.
59
+ message ClientToServer {
60
+ oneof payload {
61
+ EventRequest event = 1;
62
+ AndroidAccessibilityForest forest = 2;
63
+ }
64
+ }
65
+
66
+ // The message sent from the server running outside of the device to the Android
67
+ // device.
68
+ message ServerToClient {
69
+ // A request to obtain the Accessibility forest.
70
+ message GetA11yForest {}
71
+
72
+ oneof payload {
73
+ GetA11yForest get_forest = 1;
74
+ }
75
+ }
@@ -0,0 +1,54 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: android_env/proto/a11y/a11y.proto
5
+ # Protobuf Python Version: 5.29.0
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 5,
15
+ 29,
16
+ 0,
17
+ '',
18
+ 'android_env/proto/a11y/a11y.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+ from android_env.proto.a11y import android_accessibility_forest_pb2 as android__env_dot_proto_dot_a11y_dot_android__accessibility__forest__pb2
26
+
27
+
28
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n!android_env/proto/a11y/a11y.proto\x12\x0b\x61ndroid_env\x1a\x39\x61ndroid_env/proto/a11y/android_accessibility_forest.proto\"\x1f\n\x0e\x46orestResponse\x12\r\n\x05\x65rror\x18\x01 \x01(\t\"q\n\x0c\x45ventRequest\x12\x33\n\x05\x65vent\x18\x01 \x03(\x0b\x32$.android_env.EventRequest.EventEntry\x1a,\n\nEventEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x1e\n\rEventResponse\x12\r\n\x05\x65rror\x18\x01 \x01(\t\"\x82\x01\n\x0e\x43lientToServer\x12*\n\x05\x65vent\x18\x01 \x01(\x0b\x32\x19.android_env.EventRequestH\x00\x12\x39\n\x06\x66orest\x18\x02 \x01(\x0b\x32\'.android_env.AndroidAccessibilityForestH\x00\x42\t\n\x07payload\"m\n\x0eServerToClient\x12?\n\nget_forest\x18\x01 \x01(\x0b\x32).android_env.ServerToClient.GetA11yForestH\x00\x1a\x0f\n\rGetA11yForestB\t\n\x07payload2\xf1\x01\n\x0b\x41\x31\x31yService\x12T\n\nSendForest\x12\'.android_env.AndroidAccessibilityForest\x1a\x1b.android_env.ForestResponse\"\x00\x12\x44\n\tSendEvent\x12\x19.android_env.EventRequest\x1a\x1a.android_env.EventResponse\"\x00\x12\x46\n\x04\x42idi\x12\x1b.android_env.ClientToServer\x1a\x1b.android_env.ServerToClient\"\x00(\x01\x30\x01\x42\x30\n,com.google.androidenv.accessibilityforwarderP\x01\x62\x06proto3')
29
+
30
+ _globals = globals()
31
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
32
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'android_env.proto.a11y.a11y_pb2', _globals)
33
+ if not _descriptor._USE_C_DESCRIPTORS:
34
+ _globals['DESCRIPTOR']._loaded_options = None
35
+ _globals['DESCRIPTOR']._serialized_options = b'\n,com.google.androidenv.accessibilityforwarderP\001'
36
+ _globals['_EVENTREQUEST_EVENTENTRY']._loaded_options = None
37
+ _globals['_EVENTREQUEST_EVENTENTRY']._serialized_options = b'8\001'
38
+ _globals['_FORESTRESPONSE']._serialized_start=109
39
+ _globals['_FORESTRESPONSE']._serialized_end=140
40
+ _globals['_EVENTREQUEST']._serialized_start=142
41
+ _globals['_EVENTREQUEST']._serialized_end=255
42
+ _globals['_EVENTREQUEST_EVENTENTRY']._serialized_start=211
43
+ _globals['_EVENTREQUEST_EVENTENTRY']._serialized_end=255
44
+ _globals['_EVENTRESPONSE']._serialized_start=257
45
+ _globals['_EVENTRESPONSE']._serialized_end=287
46
+ _globals['_CLIENTTOSERVER']._serialized_start=290
47
+ _globals['_CLIENTTOSERVER']._serialized_end=420
48
+ _globals['_SERVERTOCLIENT']._serialized_start=422
49
+ _globals['_SERVERTOCLIENT']._serialized_end=531
50
+ _globals['_SERVERTOCLIENT_GETA11YFOREST']._serialized_start=505
51
+ _globals['_SERVERTOCLIENT_GETA11YFOREST']._serialized_end=520
52
+ _globals['_A11YSERVICE']._serialized_start=534
53
+ _globals['_A11YSERVICE']._serialized_end=775
54
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,49 @@
1
+ from android_env.proto.a11y import android_accessibility_forest_pb2 as _android_accessibility_forest_pb2
2
+ from google.protobuf.internal import containers as _containers
3
+ from google.protobuf import descriptor as _descriptor
4
+ from google.protobuf import message as _message
5
+ from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional, Union as _Union
6
+
7
+ DESCRIPTOR: _descriptor.FileDescriptor
8
+
9
+ class ForestResponse(_message.Message):
10
+ __slots__ = ("error",)
11
+ ERROR_FIELD_NUMBER: _ClassVar[int]
12
+ error: str
13
+ def __init__(self, error: _Optional[str] = ...) -> None: ...
14
+
15
+ class EventRequest(_message.Message):
16
+ __slots__ = ("event",)
17
+ class EventEntry(_message.Message):
18
+ __slots__ = ("key", "value")
19
+ KEY_FIELD_NUMBER: _ClassVar[int]
20
+ VALUE_FIELD_NUMBER: _ClassVar[int]
21
+ key: str
22
+ value: str
23
+ def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
24
+ EVENT_FIELD_NUMBER: _ClassVar[int]
25
+ event: _containers.ScalarMap[str, str]
26
+ def __init__(self, event: _Optional[_Mapping[str, str]] = ...) -> None: ...
27
+
28
+ class EventResponse(_message.Message):
29
+ __slots__ = ("error",)
30
+ ERROR_FIELD_NUMBER: _ClassVar[int]
31
+ error: str
32
+ def __init__(self, error: _Optional[str] = ...) -> None: ...
33
+
34
+ class ClientToServer(_message.Message):
35
+ __slots__ = ("event", "forest")
36
+ EVENT_FIELD_NUMBER: _ClassVar[int]
37
+ FOREST_FIELD_NUMBER: _ClassVar[int]
38
+ event: EventRequest
39
+ forest: _android_accessibility_forest_pb2.AndroidAccessibilityForest
40
+ def __init__(self, event: _Optional[_Union[EventRequest, _Mapping]] = ..., forest: _Optional[_Union[_android_accessibility_forest_pb2.AndroidAccessibilityForest, _Mapping]] = ...) -> None: ...
41
+
42
+ class ServerToClient(_message.Message):
43
+ __slots__ = ("get_forest",)
44
+ class GetA11yForest(_message.Message):
45
+ __slots__ = ()
46
+ def __init__(self) -> None: ...
47
+ GET_FOREST_FIELD_NUMBER: _ClassVar[int]
48
+ get_forest: ServerToClient.GetA11yForest
49
+ def __init__(self, get_forest: _Optional[_Union[ServerToClient.GetA11yForest, _Mapping]] = ...) -> None: ...
@@ -0,0 +1,202 @@
1
+ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2
+ """Client and server classes corresponding to protobuf-defined services."""
3
+ import grpc
4
+ import warnings
5
+
6
+ from android_env.proto.a11y import a11y_pb2 as android__env_dot_proto_dot_a11y_dot_a11y__pb2
7
+ from android_env.proto.a11y import android_accessibility_forest_pb2 as android__env_dot_proto_dot_a11y_dot_android__accessibility__forest__pb2
8
+
9
+ GRPC_GENERATED_VERSION = '1.71.0'
10
+ GRPC_VERSION = grpc.__version__
11
+ _version_not_supported = False
12
+
13
+ try:
14
+ from grpc._utilities import first_version_is_lower
15
+ _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
16
+ except ImportError:
17
+ _version_not_supported = True
18
+
19
+ if _version_not_supported:
20
+ raise RuntimeError(
21
+ f'The grpc package installed is at version {GRPC_VERSION},'
22
+ + f' but the generated code in android_env/proto/a11y/a11y_pb2_grpc.py depends on'
23
+ + f' grpcio>={GRPC_GENERATED_VERSION}.'
24
+ + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
25
+ + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
26
+ )
27
+
28
+
29
+ class A11yServiceStub(object):
30
+ """A service to send Accessibility information to a remote server.
31
+
32
+ The client is assumed to be running inside an Android device (e.g. emulator
33
+ or real device) while the server is assumed to be running outside (e.g. in a
34
+ Python process).
35
+ """
36
+
37
+ def __init__(self, channel):
38
+ """Constructor.
39
+
40
+ Args:
41
+ channel: A grpc.Channel.
42
+ """
43
+ self.SendForest = channel.unary_unary(
44
+ '/android_env.A11yService/SendForest',
45
+ request_serializer=android__env_dot_proto_dot_a11y_dot_android__accessibility__forest__pb2.AndroidAccessibilityForest.SerializeToString,
46
+ response_deserializer=android__env_dot_proto_dot_a11y_dot_a11y__pb2.ForestResponse.FromString,
47
+ _registered_method=True)
48
+ self.SendEvent = channel.unary_unary(
49
+ '/android_env.A11yService/SendEvent',
50
+ request_serializer=android__env_dot_proto_dot_a11y_dot_a11y__pb2.EventRequest.SerializeToString,
51
+ response_deserializer=android__env_dot_proto_dot_a11y_dot_a11y__pb2.EventResponse.FromString,
52
+ _registered_method=True)
53
+ self.Bidi = channel.stream_stream(
54
+ '/android_env.A11yService/Bidi',
55
+ request_serializer=android__env_dot_proto_dot_a11y_dot_a11y__pb2.ClientToServer.SerializeToString,
56
+ response_deserializer=android__env_dot_proto_dot_a11y_dot_a11y__pb2.ServerToClient.FromString,
57
+ _registered_method=True)
58
+
59
+
60
+ class A11yServiceServicer(object):
61
+ """A service to send Accessibility information to a remote server.
62
+
63
+ The client is assumed to be running inside an Android device (e.g. emulator
64
+ or real device) while the server is assumed to be running outside (e.g. in a
65
+ Python process).
66
+ """
67
+
68
+ def SendForest(self, request, context):
69
+ """Sends a forest of Accessibility trees to a server.
70
+ """
71
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
72
+ context.set_details('Method not implemented!')
73
+ raise NotImplementedError('Method not implemented!')
74
+
75
+ def SendEvent(self, request, context):
76
+ """Sends an a11y event to a server.
77
+ """
78
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
79
+ context.set_details('Method not implemented!')
80
+ raise NotImplementedError('Method not implemented!')
81
+
82
+ def Bidi(self, request_iterator, context):
83
+ """Long-lived bidirection communication between the client and the server.
84
+ """
85
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
86
+ context.set_details('Method not implemented!')
87
+ raise NotImplementedError('Method not implemented!')
88
+
89
+
90
+ def add_A11yServiceServicer_to_server(servicer, server):
91
+ rpc_method_handlers = {
92
+ 'SendForest': grpc.unary_unary_rpc_method_handler(
93
+ servicer.SendForest,
94
+ request_deserializer=android__env_dot_proto_dot_a11y_dot_android__accessibility__forest__pb2.AndroidAccessibilityForest.FromString,
95
+ response_serializer=android__env_dot_proto_dot_a11y_dot_a11y__pb2.ForestResponse.SerializeToString,
96
+ ),
97
+ 'SendEvent': grpc.unary_unary_rpc_method_handler(
98
+ servicer.SendEvent,
99
+ request_deserializer=android__env_dot_proto_dot_a11y_dot_a11y__pb2.EventRequest.FromString,
100
+ response_serializer=android__env_dot_proto_dot_a11y_dot_a11y__pb2.EventResponse.SerializeToString,
101
+ ),
102
+ 'Bidi': grpc.stream_stream_rpc_method_handler(
103
+ servicer.Bidi,
104
+ request_deserializer=android__env_dot_proto_dot_a11y_dot_a11y__pb2.ClientToServer.FromString,
105
+ response_serializer=android__env_dot_proto_dot_a11y_dot_a11y__pb2.ServerToClient.SerializeToString,
106
+ ),
107
+ }
108
+ generic_handler = grpc.method_handlers_generic_handler(
109
+ 'android_env.A11yService', rpc_method_handlers)
110
+ server.add_generic_rpc_handlers((generic_handler,))
111
+ server.add_registered_method_handlers('android_env.A11yService', rpc_method_handlers)
112
+
113
+
114
+ # This class is part of an EXPERIMENTAL API.
115
+ class A11yService(object):
116
+ """A service to send Accessibility information to a remote server.
117
+
118
+ The client is assumed to be running inside an Android device (e.g. emulator
119
+ or real device) while the server is assumed to be running outside (e.g. in a
120
+ Python process).
121
+ """
122
+
123
+ @staticmethod
124
+ def SendForest(request,
125
+ target,
126
+ options=(),
127
+ channel_credentials=None,
128
+ call_credentials=None,
129
+ insecure=False,
130
+ compression=None,
131
+ wait_for_ready=None,
132
+ timeout=None,
133
+ metadata=None):
134
+ return grpc.experimental.unary_unary(
135
+ request,
136
+ target,
137
+ '/android_env.A11yService/SendForest',
138
+ android__env_dot_proto_dot_a11y_dot_android__accessibility__forest__pb2.AndroidAccessibilityForest.SerializeToString,
139
+ android__env_dot_proto_dot_a11y_dot_a11y__pb2.ForestResponse.FromString,
140
+ options,
141
+ channel_credentials,
142
+ insecure,
143
+ call_credentials,
144
+ compression,
145
+ wait_for_ready,
146
+ timeout,
147
+ metadata,
148
+ _registered_method=True)
149
+
150
+ @staticmethod
151
+ def SendEvent(request,
152
+ target,
153
+ options=(),
154
+ channel_credentials=None,
155
+ call_credentials=None,
156
+ insecure=False,
157
+ compression=None,
158
+ wait_for_ready=None,
159
+ timeout=None,
160
+ metadata=None):
161
+ return grpc.experimental.unary_unary(
162
+ request,
163
+ target,
164
+ '/android_env.A11yService/SendEvent',
165
+ android__env_dot_proto_dot_a11y_dot_a11y__pb2.EventRequest.SerializeToString,
166
+ android__env_dot_proto_dot_a11y_dot_a11y__pb2.EventResponse.FromString,
167
+ options,
168
+ channel_credentials,
169
+ insecure,
170
+ call_credentials,
171
+ compression,
172
+ wait_for_ready,
173
+ timeout,
174
+ metadata,
175
+ _registered_method=True)
176
+
177
+ @staticmethod
178
+ def Bidi(request_iterator,
179
+ target,
180
+ options=(),
181
+ channel_credentials=None,
182
+ call_credentials=None,
183
+ insecure=False,
184
+ compression=None,
185
+ wait_for_ready=None,
186
+ timeout=None,
187
+ metadata=None):
188
+ return grpc.experimental.stream_stream(
189
+ request_iterator,
190
+ target,
191
+ '/android_env.A11yService/Bidi',
192
+ android__env_dot_proto_dot_a11y_dot_a11y__pb2.ClientToServer.SerializeToString,
193
+ android__env_dot_proto_dot_a11y_dot_a11y__pb2.ServerToClient.FromString,
194
+ options,
195
+ channel_credentials,
196
+ insecure,
197
+ call_credentials,
198
+ compression,
199
+ wait_for_ready,
200
+ timeout,
201
+ metadata,
202
+ _registered_method=True)
@@ -0,0 +1,32 @@
1
+ // Copyright 2024 DeepMind Technologies Limited.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ syntax = "proto3";
16
+
17
+ package android_env;
18
+
19
+ option java_multiple_files = true;
20
+ option java_package = "com.google.androidenv.accessibilityforwarder";
21
+
22
+ // An Android Accessibility Action.
23
+ // Next index: 3
24
+ message AndroidAccessibilityAction {
25
+ // Required ID that uniquely identifies the action for this node.
26
+ // Can be one of the standard action IDs listed in the documentation.
27
+ // https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.AccessibilityAction
28
+ int32 id = 1;
29
+
30
+ // Optional label describing what the action is.
31
+ string label = 2;
32
+ }