How to check if a package is enabled via shell? I have been writing a tasker task to enable/disable a package. I know 

adb shell pm enable com.android.contacts  

will enable the package and

adb shell pm disable com.android.contacts  

will disable it.

I would like to know if there's any shell command that would tell me if a package is in enabled/disabled state. Thanks in advance! :)
pm list packages -d 2&gt;/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&gt;/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).