Skip to content
Open
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
24 changes: 22 additions & 2 deletions android_env/components/adb_call_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

"""Processes adb_pb2.AdbRequest commands."""

import base64
import os
import re
import subprocess
Expand Down Expand Up @@ -616,8 +617,27 @@ def _input_text(
status=adb_pb2.AdbResponse.Status.FAILED_PRECONDITION,
error_message='InputText.text is empty.')

response, _ = self._execute_command(['shell', 'input', 'text', text],
timeout=timeout)
is_ascii = text.isascii()

if is_ascii:
response, _ = self._execute_command(
['shell', 'input', 'text', text], timeout=timeout
)
else:
b64_text = base64.b64encode(text.encode('utf-8')).decode('ascii')
response, _ = self._execute_command(
[
'shell',
'am',
'broadcast',
'-a',
'ADB_INPUT_B64',
'--es',
'msg',
b64_text,
],
timeout=timeout,
)
return response

def _tap(
Expand Down