Skip to content

Commit

Permalink
Introduce Accessibility Protobuf messages.
Browse files Browse the repository at this point in the history
These messages encode accessibility information coming from Android OS. Actual
components that use them will come later.

PiperOrigin-RevId: 631418985
  • Loading branch information
kenjitoyama authored and copybara-github committed May 7, 2024
1 parent df730c3 commit ed431e9
Show file tree
Hide file tree
Showing 8 changed files with 458 additions and 0 deletions.
76 changes: 76 additions & 0 deletions android_env/proto/a11y/a11y.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2024 DeepMind Technologies Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package android_env;

import "third_party/py/android_env/proto/a11y/android_accessibility_forest.proto";

option java_multiple_files = true;
option use_java_stubby_library = true;
option java_package = "com.google.androidenv.accessibilityforwarder";

// A service to send Accessibility information to a remote server.
//
// The client is assumed to be running inside an Android device (e.g. emulator
// or real device) while the server is assumed to be running outside (e.g. in a
// Python process).
service A11yService {
// Sends a forest of Accessibility trees to a server.
rpc SendForest(AndroidAccessibilityForest) returns (ForestResponse) {}
// Sends an a11y event to a server.
rpc SendEvent(EventRequest) returns (EventResponse) {}

// Long-lived bidirection communication between the client and the server.
rpc Bidi(stream ClientToServer) returns (stream ServerToClient) {}
}

// TODO(b/334952387): Remove `ForestResponse`, `EventRequest` and
// `EventResponse` once bidi communication is in-place.
message ForestResponse {
// The error if anything.
string error = 1;
}

// An Accessibility event.
message EventRequest {
// A single event as a dictionary.
map<string, string> event = 1;
}

message EventResponse {
// The error if anything.
string error = 1;
}

// The message sent from the Android device to the server running outside of the
// device.
message ClientToServer {
oneof payload {
EventRequest event = 1;
AndroidAccessibilityForest forest = 2;
}
}

// The message sent from the server running outside of the device to the Android
// device.
message ServerToClient {
// A request to obtain the Accessibility forest.
message GetA11yForest {}

oneof payload {
GetA11yForest get_forest = 1;
}
}
33 changes: 33 additions & 0 deletions android_env/proto/a11y/android_accessibility_action.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2024 DeepMind Technologies Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package android_env;

option java_multiple_files = true;
option java_package = "com.google.androidenv.accessibilityforwarder";
option java_api_version = 2;

// An Android Accessibility Action.
// Next index: 3
message AndroidAccessibilityAction {
// Required ID that uniquely identifies the action for this node.
// Can be one of the standard action IDs listed in the documentation.
// https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo.AccessibilityAction
int32 id = 1;

// Optional label describing what the action is.
string label = 2;
}
30 changes: 30 additions & 0 deletions android_env/proto/a11y/android_accessibility_forest.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2024 DeepMind Technologies Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package android_env;

import "third_party/py/android_env/proto/a11y/android_accessibility_window_info.proto";

option java_multiple_files = true;
option java_package = "com.google.androidenv.accessibilityforwarder";
option java_api_version = 2;

// A forest of Android accessibility trees. Each tree belongs to a single
// window. Next index: 2
message AndroidAccessibilityForest {
// All of the windows present on screen.
repeated AndroidAccessibilityWindowInfo windows = 1;
}
123 changes: 123 additions & 0 deletions android_env/proto/a11y/android_accessibility_node_info.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Copyright 2024 DeepMind Technologies Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package android_env;

import "third_party/py/android_env/proto/a11y/android_accessibility_action.proto";
import "third_party/py/android_env/proto/a11y/android_accessibility_node_info_clickable_span.proto";
import "third_party/py/android_env/proto/a11y/rect.proto";

option java_multiple_files = true;
option java_package = "com.google.androidenv.accessibilityforwarder";
option java_api_version = 2;

// An Android AccessibilityNodeInfo.
// Next index: 32
message AndroidAccessibilityNodeInfo {
// Unique monotonically-increasing ID.
int32 unique_id = 1;

// The bounds of this node within the device's screen.
ProtoRect bounds_in_screen = 2;

// The name of the View class that created this node.
string class_name = 3;

// The content description of the node.
string content_description = 4;

// The hint text of the node.
string hint_text = 5;

// The name of the package this node comes from.
string package_name = 6;

// The text of this node.
string text = 7;

// The start index of the text selection.
int64 text_selection_start = 8;

// The end index of the text selection.
int64 text_selection_end = 9;

// The view ID resource name of the node.
string view_id_resource_name = 10;

// The ID of the window this node belongs to.
int32 window_id = 11;

// If true, this node can be checked.
bool is_checkable = 12;

// If true, this node is currently checked.
bool is_checked = 13;

// If true, this node (probably) responds to being clicked.
bool is_clickable = 14;

// If true, this node's text can be edited by the user.
bool is_editable = 15;

// If true, this node is enabled (e.g., if it is a button).
bool is_enabled = 16;

// If true, this node can be focused (e.g., a text input).
bool is_focusable = 17;

// If true, this node is currently focused.
bool is_focused = 18;

// If true, this node (probably) responds to being long pressed.
bool is_long_clickable = 19;

// If true, this node is a password input.
bool is_password = 20;

// If true, this node can be scrolled.
bool is_scrollable = 21;

// If true, this node is currently selected.
bool is_selected = 22;

// If true, this node is (probably) visible to the user.
bool is_visible_to_user = 23;

// List of actions that can be performed on this node.
repeated AndroidAccessibilityAction actions = 24;

// Ordered list of child IDs (i.e., unique_id).
repeated int32 child_ids = 25 [packed = true];

// List of clickable spans present in the node's text or content description.
repeated AndroidAccessibilityNodeInfoClickableSpan clickable_spans = 26;

// The depth of this node in the accessibility tree.
int32 depth = 27;

// Unique ID of the node that this node is declaring itself to be labeled by.
int32 labeled_by_id = 28;

// Unique ID of the node that this is node is declaring itself to be a label
// for.
int32 label_for_id = 29;

// The drawing order for the node.
int32 drawing_order = 30;

// The tooltip text of the node.
string tooltip_text = 31;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2024 DeepMind Technologies Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package android_env;

option java_multiple_files = true;
option java_package = "com.google.androidenv.accessibilityforwarder";
option java_api_version = 2;

// A single clickable span found in the accessibility node's text.
// Next index: 6
message AndroidAccessibilityNodeInfoClickableSpan {
// The source of the span (so the client can find the correct spannable string
// in the node).
// Next index: 3
enum SpanSource {
UNKNOWN_TYPE = 0; // Catch all type for forward compatibility.
TEXT = 1; // The span is from node#getText
CONTENT_DESCRIPTION = 2; // The span is from node#getContentDescription.
}

// The text of the span (a substring of the spannable string).
string text = 1;

// The URL attached to the span if specified.
string url = 2;

// The source of the span.
SpanSource source = 3;

// The index of the first character of the span in the spannable string.
// The end of the span would be a sum of span_start and text.length().
int32 start = 4;

// The unique_id from the corresponding AndroidAccessibilityNodeInfo.
int32 node_id = 5;
}
30 changes: 30 additions & 0 deletions android_env/proto/a11y/android_accessibility_tree.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2024 DeepMind Technologies Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package android_env;

import "third_party/py/android_env/proto/a11y/android_accessibility_node_info.proto";

option java_multiple_files = true;
option java_package = "com.google.androidenv.accessibilityforwarder";
option java_api_version = 2;

// A tree (actually a graph) of Android accessibility nodes.
// Next index: 3
message AndroidAccessibilityTree {
// All of the nodes in the graph. The root node is the node whose ID is 0.
repeated AndroidAccessibilityNodeInfo nodes = 1;
}
Loading

0 comments on commit ed431e9

Please sign in to comment.