0

You can "suspend" user apps via cmd package suspend <packageName> (which acts kind of like pm disable; the differences are explained in this answer by @Firelord), and later unsuspend them using cmd package unsuspend <packageName> – which also works for user-installed apps. However: suspended packages seem no longer to be listed via cmd package list packages – not even if -u (uninstalled) or -d (disabled) is specified; not even dumpsys package seems to know them anymore.

So is there any way to obtain a list of suspended packages? The syntax output doesn't mention such. But as such apps are still shown in the launcher (though "grayed out"), there must be a way to detect them.

1 Answer 1

1

I'm not particularly good with bash scripts so I'm posting a bit of an ugly one-liner which prints the packages which are currently suspended. Tested on Android 11 and 12 (both Android Emulator).

Works without root access:

adb shell
pm list packages -a | sed -e 's/^package://'| while read package; do status="$(dumpsys package $package | grep -o "suspended=true")"; if [[ "$status" == "suspended=true" ]] then echo "$package"; fi; done

What we are doing in simpler terms is get package names of all the installed apps; then for each package dump its content using dumpsys package, and within each dump check for the string which et al mentions this substring suspended=true. If found, we print the package name, otherwise, we skip to the next package name and repeat the process.

If you have root access (won't work on Android 12):

adb shell
su
grep 'suspended="true"' /data/system/users/0/package-restrictions.xml | cut -d '"' -f2

This is very fast compared to non-root solution. Also prints names of packages which are currently suspended.

2
  • 1
    Thanks – but the first command again does not show the suspended packages (also not if replaced by the corresponding newer cmd command – both yield "unknown option -a"). The second one did the trick after a slight modification: I had to ommit the ="true" for some reason I don't get. But adb shell su -c grep 'suspended' /data/system/users/0/package-restrictions.xml | cut -d '"' -f2 indeed did the trick, thanks!
    – Izzy
    Commented Jun 13, 2022 at 21:17
  • 1
    PS: moving the grep back to the PC also works: adb shell su -c cat /data/system/users/0/package-restrictions.xml |grep 'suspended="true"'| cut -d '"' -f2
    – Izzy
    Commented Jun 13, 2022 at 21:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .