-
-
Save davidnunez/1404789 to your computer and use it in GitHub Desktop.
pm list packages -f |
@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.
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.