New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace 'pm list packages' with 'dumpsys package' #130
Conversation
adbe/adb_enhanced.py
Outdated
cmd = 'dumpsys package' | ||
grep_cmd = 'grep -Po "Package \[\K[^\]]+"' | ||
apps_list = execute_adb_shell_command(cmd, piped_into_cmd=grep_cmd) | ||
# packages = _get_all_packages(cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this commented out code.
adbe/adb_enhanced.py
Outdated
lambda p : p not in runtime_granted_permissions and | ||
p not in runtime_denied_permissions and | ||
p not in install_time_granted_permissions and | ||
p not in install_time_denied_permissions, requested_permissions)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continuation line unaligned for hanging indent
adbe/adb_enhanced.py
Outdated
_ASYNCIO_AVAILABLE = True | ||
except ImportError: | ||
except ImportError : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace before ':'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert
adbe/adb_enhanced.py
Outdated
# This is to deal with python versions below 3.5 | ||
_ASYNCIO_AVAILABLE = False | ||
else: | ||
else : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace before ':'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert
adbe/adb_enhanced.py
Outdated
_ASYNCIO_AVAILABLE = False | ||
|
||
try: | ||
try : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace before ':'
adbe/adb_enhanced.py
Outdated
if activity_name.startswith('.'): | ||
activity_name = '%s%s' %(app_name, activity_name) | ||
return app_name, activity_name | ||
if line.startswith('mFocusedApp'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change intentional? I think this is the exact code that I removed in 69bb243
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, I forked the master branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just do a git pull origin master
in that case. Your branch has become stale. I changed this code <24 hours ago.
adbe/adb_enhanced.py
Outdated
cmd = 'pm list packages' | ||
packages = _get_all_packages(cmd) | ||
print('\n'.join(packages)) | ||
# The command "pm list packages -e" does not return all installed and enabled Apps, the alternative is to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what exactly does pm list packages -e
miss? Disabled apps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pm list packages -e
for some unknown reason does not list some enabled apps.
-e
should show all enabled Apps including system Apps which is not the case as discussed in the thread: https://stackoverflow.com/questions/63416599/adb-shell-pm-list-packages-missing-some-packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. It is fine if we don't know the underlying cause. Add this StackOverflow thread in the code comments as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that the regex is reported as an anomaly by DeepSource Python, Can we replace it by this one dumpsys package | grep "Package \[" | cut -d "\[" -f2 | cut -d "\]" -f1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new code is fine. Just confirm that cut
command's arguments are the same on both Linux and Mac.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be the same (https://superuser.com/questions/179368/how-does-macs-command-line-compare-to-linux), unfortunately I do not have a Mac to test. Can someone else confirm that please ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got cut: bad delimiter
as an error on Mac OS. How about we do this parsing in Python instead? That's much more portable as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sure, I will update it.
adbe/adb_enhanced.py
Outdated
@@ -1562,43 +1579,3 @@ def switch_screen(switch_type): | |||
"screen control operation. Error: %s" % e) | |||
|
|||
return o | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase your code to avoid reverting this addition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Sorry for that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
Command output:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved pending the addition of StackOverflow thread as a comment for future reference.
Code Climate has analyzed commit 4115230 and detected 5 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
So, I checked |
return_code, result, _ = execute_adb_shell_command2(cmd) | ||
if return_code != 0: | ||
print_error_and_exit('Command "%s" failed, something is wrong' % cmd) | ||
all_apps = re.findall(pattern_packages, result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not printing the results. I will fix that in #135
In some cases, the command 'pm list packages' will not list all enabled third party packages (same for -e and -s).
https://stackoverflow.com/questions/63416599/adb-shell-pm-list-packages-missing-some-packages