This repository has been archived by the owner on May 27, 2024. It is now read-only.
handle multiline pm path packagename output #111
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello!
Just found a problem handling the return of adb shell pm path packagename
I don't know why but it may return more packages and that will cause an error for uiautomator2 when starting the app without specific activities, because
d.app_info(packagename)
will ask atx-agent to find the package with the wrong name.which returns the error:
because in your code you're removing trailing spaces and \n, so you have a long string which is the mix of the two paths.
For your app, for example, it's only one row:
d.shell(["pm", "path", "com.github.uiautomator"])
ShellResponse(output='package:/data/app/com.github.uiautomator-QhCGbZTc-k5orXu8c81syw==/base.apk\n', exit_code=0)
And the code works correctly.
For Instagram you have something like that (in the last release):
ShellResponse(output='package:/data/app/com.instagram.android-bHoeaeqTH_3wNr4o9hp3tw==/base.apk\npackage:/data/app/com.instagram.android-bHoeaeqTH_3wNr4o9hp3tw==/split_pytorch.apk\n', exit_code=0)
which needs a little bit of string manipulation.
I've split the output where \n occurs and returned only the first row. That should work with one-row cases and multi-row cases.