pm list packages -d 2>/dev/null
will list up all disabled packages, one per line, preceded with the keyword package:
– so output looks like
package:com.android.exchange
package:com.android.email
So if you take that output and "grep" it for the package name in question, the package is enabled if the output is "empty" and disabled otherwise. Alternatively, if you want a number (0/1), you can use the wc
utility:
pm list packages -d 2>/dev/null | grep com.android.exchange | wc -l
would return "1" in above example, meaning the package com.android.exchange
is disabled. It would, however, return "0" if I'd grep for com.foobar.app
– which doesn't necessarily mean that com.foobar.app
is enabled but could also mean it's simply not installed :) So if you want to cross-check, you can do so running the same command with pm list packages -e
(to list enabled packages).