AppAgent icon indicating copy to clipboard operation
AppAgent copied to clipboard

adb shell input text error

Open madroidmaq opened this issue 1 year ago • 2 comments

Using adb shell input text will result in the following error message when multiple strings are entered into the text box:

adb -s emulator-5554 shell input text "app agent test"

The error message is as follows:

Exception occurred while executing 'text':
java.lang.NullPointerException: Attempt to get length of null array
        at com.android.server.input.InputShellCommand.sendText(InputShellCommand.java:319)
        at com.android.server.input.InputShellCommand.runText(InputShellCommand.java:291)
        at com.android.server.input.InputShellCommand.onCommand(InputShellCommand.java:232)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.server.input.InputManagerService.onShellCommand(InputManagerService.java:3297)
        at android.os.Binder.shellCommand(Binder.java:1068)
        at android.os.Binder.onTransact(Binder.java:888)
        at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:1339)
        at android.os.Binder.execTransactInternal(Binder.java:1344)
        at android.os.Binder.execTransact(Binder.java:1275)

madroidmaq avatar Jan 15 '24 04:01 madroidmaq

same error

wildwind0 avatar Jan 24 '24 04:01 wildwind0

    def text(self, input_str):
        input_str = input_str.replace(" ", "%s")
        input_str = input_str.replace("'", "")
        adb_command = f"adb -s {self.device} shell input text {input_str}"
        ret = execute_adb(adb_command)
        return ret

I noticed that the project has implemented simple adaptations by replacing spaces and single quotes, and it works fine in my tests. I'm not sure if this is due to the input method?

twiceyuan avatar Jan 24 '24 07:01 twiceyuan