Skip to content

Commit

Permalink
Send explicit broadcasts to SET_GRPC and ENABLE_A11Y_TREE_LOGS.
Browse files Browse the repository at this point in the history
changes:
-add component field to SendBroadcast in AdbRequest
-change the send broadcast function in the call parser to pass the component name if present in the request
-in the a11y grpc wrapper, set the component name to match FlagsBroadcastReceiver
PiperOrigin-RevId: 581326914
  • Loading branch information
DeepMind authored and copybara-github committed Nov 10, 2023
1 parent ea0bb87 commit 49e38e0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
26 changes: 21 additions & 5 deletions android_env/components/adb_call_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,32 @@ def _send_broadcast(
An AdbResponse.
"""

send_brodcast = request.send_broadcast
send_broadcast = request.send_broadcast
response = adb_pb2.AdbResponse(status=adb_pb2.AdbResponse.Status.OK)
if not send_brodcast.action:
if not send_broadcast.action:
response.status = adb_pb2.AdbResponse.Status.FAILED_PRECONDITION
response.error_message = ('`send_broadcast.{action}` cannot be empty.')
return response

response, _ = self._execute_command(
['shell', 'am', 'broadcast', '-a', send_brodcast.action],
timeout=timeout)
if send_broadcast.component:
response, _ = self._execute_command(
[
'shell',
'am',
'broadcast',
'-a',
send_broadcast.action,
'-n',
send_broadcast.component,
],
timeout=timeout,
)
else:
response, _ = self._execute_command(
['shell', 'am', 'broadcast', '-a', send_broadcast.action],
timeout=timeout,
)

return response

def _install_apk(
Expand Down
5 changes: 5 additions & 0 deletions android_env/proto/adb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ message AdbRequest {
message SendBroadcast {
// Action to send during the broadcast event.
string action = 1;

// Specify the component name with package name prefix to create an explicit
// intent, such as com.example.app/.ExampleActivity (see -n specification at
// https://developer.android.com/tools/adb#IntentSpec).
string component = 2;
}

message UninstallPackage {
Expand Down

0 comments on commit 49e38e0

Please sign in to comment.