-
-
Save davidnunez/1404789 to your computer and use it in GitHub Desktop.
pm list packages -f |
Need help!
How to get the uses permission on all app installed?
Need help! How to get the uses permission on all app installed?
First, I know the thread is old but for all newcomers who entering the cli nix world of android I just want to say: 'pm' has been moved to become 'cmd' command instead (Call package manager) you might have seen a note on earlier android versions: NOTE: 'pm list' commands have moved! Run 'adb shell cmd package
Back to the real topic and why I came here. @sameerppradhan here is how you can list all permissions for all apps on device, I also toke some time and wrote down some other examples about listning persmissions
Below command will do what you asking for, printing * permissions for all apps installed
cmd package list permissions
cmd package list permissions|wc -l
1752
Example Output
permission:com.samsung.android.app.clockpack.LOCK_PROVIDER
permission:com.sec.epdgtestapp.permission.SERVICE
permission:com.samsung.android.mobilservice.MIGRATION_READ
permission:android.permission.ADJUST_RUNTIME_PERMISSIONS_POLICY
permission:com.microsoft.appmanager.BIND_CACHE_SERVICE_PERMISSION
permission:com.samsung.android.app.telephonyui.permission.USE_PHOTORING
permission:com.samsung.android.bixby.agent.permission.APP_SERVICE
permission:com.google.android.gms.chromesync.permission.METADATA_UPDATED
permission:com.samsung.android.mcfds.permission.DISABLE_HANDOFF
permission:com.sec.android.app.samsungapps.accesspermission.GENERNAL_ACTIVITY
permission:com.samsung.android.permission.SEM_AUTO_BIND_NOTIFICATION_LISTENER_SERVICE
....
And some more examples you can use:
Print permissions organized by group
cmd package list permissions -g
Print all information that is given for all aplications
cmd package list permissions -f
Just print short summary of permissions of all applications
cmd package list permissions -s
Print only the flagged permissions that is consider as dangerous for all applications
cmd package list permissions -d
Print only the permissdions the user user you choose to check will see (cmd list users for find users to choose between)
cmd package list permissions -u
- And you probably already figured it out, if you want to check specifik apps only just add the app name at end of the lines.
- wuseman
For anyone wondering about full command using adb adb shell pm list packages -f
worked for me
For finding version info you can run adb shell "dumpsys package packages"
which gets all package info; then you'd have to parse the output in your language of choice to pull just the package and versionName info.
@JohnLBevan This works, but how exactly do you get the app-name out of it?
Also, what do you mean "parse the output in your language of choice" ? Isn't it always in English? How would you choose a different language ? Please show an example of when it isn't in English, and why.
@JohnLBevan This works, but how exactly do you get the app-name out of it?
Ah sorry - I was describing how to get the package version; not the app.
Also, what do you mean "parse the output in your language of choice" ? Isn't it always in English? How would you choose a different language ? Please show an example of when it isn't in English, and why.
I'm talking programming/scriping/shell language, rather than human language.
@JohnLBevan Oh ok.
Do you know perhaps if it's possible to parse any kind of APK file using adb? Maybe it could help with finding the app-name?
I also wonder if there is a way to fetch the app-icon.
Hey @AndroidDeveloperLB I'm afraid I don't know much about adb itself... Best to post questions somewhere like https://android.stackexchange.com/ to get help from the community at large.
@JohnLBevan OK thanks.
Get every ID from app
for i in $(pm list packages -U | cut -f 3 -d ":"); do echo $(id -un $i); done;
@AndroidDeveloperLB
You get apps name with the corresponding package name, you just need a Linux machine with aapt binary to get the app name
aapt download links
https://androidaapt.com/
https://aaptdownload.com/
And the links to the script that will get the app and package name
https://stackoverflow.com/a/73186928
https://stackoverflow.com/a/67654499
@cpuuntery Linux? Does it mean I can do it even on Android itself?
Yes, you can run it inside termux or adb shell,
but you need to find a version of aapt compiled for arm64
the appt in my link are compiled for x86
and if you managed to run appt on android
there is even a script in the case that you want to run aapt on android provided that you have arm64 aapt. and you can filter based on permission usage
#!/system/bin/sh
# List package name of all the installed apps and save them in the file packages.txt under /sdcard
pm list packages | sed 's/^package://g' | sort -o /sdcard/packages.txt
# For each package name in the output we just saved, get the app's label using $path and $label, print a line and then finally list the permissions granted to the app
while read line; do
path=$(pm path $line | sed 's/^package://g');
label=$($aapt d badging $path | grep 'application: label=' | cut -d "'" -f2);
printf "Permissions for app $label having package name $line\n";
dumpsys package $line | sed -e '1,/grantedPermissions:/d' -e '/^\s*$/,$d' | sort;
printf "\n";
done < /sdcard/packages.txt
(you can remove the busybox part from the script above because they are not needed)
@AndroidDeveloperLB
i was able to make the old script work.
The first thing you need to do is to get the aapt binary from this repo
note aapt2 is the newer version of appt, but it is slower in parsing the data from apk files only use aapt2 when you get errors with aapt
the repo will find android 9 and android 11 choose the closest one to the version of your android device
copy aapt to /data/local/tmp
if you plan to use adb shell
or
copy appt to data/data/com.termux/files/home
if you use termux
then
chmod -R 770 *
for termux you need to give it a special permission using adb
adb shell pm grant com.termux android.permission.DUMP
and lastly there will be three versions of the script
the first will be aapt list all apps names
the second appt list app based on permission usage
the third will be appt2 list all apps
Remember to change appt or appt2 to the path of your files (it is the second line in the script)
aapt list all apps names
#!/system/bin/sh
aapt=/data/local/tmp/aapt/aapt
pm list packages | sed 's/^package://g' | while read line; do
path=$(pm path $line | sed 's/^package://g');
label=$($aapt d badging $path | grep 'application: label=' | cut -d "'" -f2);
printf "app $label having package name $line\n";
printf "\n";
done
appt list app based on permission usage
#!/system/bin/sh
aapt=/data/local/tmp/aapt/aapt
pm list packages | sed 's/^package://g' | while read line; do [[ `dumpsys package $line | grep 'android.permission.INTERNET'` ]] && echo "$line"; done | while read line; do
path=$(pm path $line | sed 's/^package://g');
label=$($aapt d badging $path | grep 'application: label=' | cut -d "'" -f2);
printf "app $label having package name $line\n";
printf "\n";
done
appt2 list all apps
#!/system/bin/sh
aapt2=/data/local/tmp/aapt2/aapt2
pm list packages | sed 's/^package://g' | while read line; do
path=$(pm path $line | sed 's/^package://g');
label=$($aapt2 dump $path | grep -A 1 string/app_name | grep -o -m 1 '".*"' | cut -d '"' -f2);
printf "app $label having package name $line\n";
printf "\n";
done
adb shell 'pm list packages' | sed 's/.*://g'
thx worked well
What is the command that shows the list of user-installed applications on the Android Phone?
What is the command that shows the list of user-installed applications on the Android Phone?
pm list packages -3
(as in 3-rd party)
That fortunately requires root to work
(as in 3-rd party)
That fortunately requires root to work
@Anubioz Thank you for your reply. However, my phone is not rooted. I will look for an alternative solution and let you know if I find anything.
I'm running this from Termux and I'm getting the error:
cmd: Failure calling service package: Failed transaction (2147483646)