Skip to content

Conversation

annonm
Copy link

@annonm annonm commented Jan 14, 2025

Summary

Hello @JeffLIrion ! I've been making use of your adb-shell project (thanks for the work on that), and realized there was a feature I could really use. It seems like others are looking for this change as well, and I thought instead of just asking for it to be done, I'd try offering a contribution via a PR:

This PR adds support for making use of the newer "shell protocol" service which can return separate stdout/stderr streams, as well as return exit code information from the shell.

Changes Made

  • Added new shell_v2 function to AdbDevice and AdbDeviceAsync
  • Added logic to parse whether device supports this style call in connect method

Here is what it looks like in action:

>>> device1.shell_v2('echo TEST')
{'stdout': 'TEST\n', 'stderr': '', 'return_code': 0}

>>> device1.shell_v2('ls /data/local/tmp/testing/existing_file /data/local/tmp/testing/does_not_exist')
{'stdout': '/data/local/tmp/testing/existing_file\n', 'stderr': 'ls: /data/local/tmp/testing/does_not_exist: No such file or directory\n', 'return_code': 1}

Related Issue

Addresses #217

Checklist

  • Changes tested locally on my personal device
  • Unit tests added
  • README updated
  • Added TODOs where confirmation is needed for devices I could not test
  • Async version of the code stubbed out, but am not super familiar with using async (you may want to double check my changes there)

Do you think this is a candidate for getting merged to adb-shell main? It would extremely useful for me, if it could get merged/tagged (in some form or another.) Open to any suggestions/changes you would have.

…ormation, as well as the return code from the shell execution
@annonm
Copy link
Author

annonm commented Jan 19, 2025

Checking in - any chance someone would be able to look at this?

@Davidjmartin423
Copy link

This would be very helpful -- would love for it to be considered!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants