we can use pm list packages -d to list disabled packages.

but how can I list disabled feature/component inside a package?

for example I disable all fitness related stuff from gms

pm disable com.google.android.gms/.fitness.sync.FitnessSyncAdapterService and so on

and I want to have an overview again which feature I have disabled


Not as straight-forward as listing packages. Here's an except (Bash code) on how my tool Adebar does it (for all apps on a device, spooling results to a file as pm disable comands in the way your question quotes it), to be found in lib/scriptgen.lib:

  local comps
  local myline
  echo "#!${BASH_LOCATION}" > "${scriptname}"
  echo -e "\n#\n# Disabled components for ${DEVICE_NAME} as of $(date '+%Y-%m-%d %H:%M')\n#" >> "${scriptname}"
  for pkg in $(adb ${ADBOPTS} shell "pm list packages 2>/dev/null"); do
    [[ "${pkg}" = "android" ]] && continue
    comps=$(adb ${ADBOPTS} shell "dumpsys package ${pkg}" | grep -E -A99999 "disabledComponents:" |grep -E -B99999 "enabledComponents:")
    if [[ -n "${comps}" ]]; then
      echo >> "${scriptname}"
      echo "# ${pkg}" >> "${scriptname}"
      for myline in $comps; do
        [[ "${myline}" = "disabledComponents:" || "${myline}" = "enabledComponents:" ]] && continue
        echo "adb ${ADBOPTS} shell \"pm disable ${pkg}/${myline}\"" >> "${scriptname}"

In short: You'd have to parse the "disabledComponents" section from the output of dumpsys package <package_name> ("comps" in above code fragment). As you can see, that segment is followed by a list of enabled components, in case you want to know where to find those.

  • 1
    nice Adebar and IzzyOnDroid! – rnd_nr_gen Apr 15 '18 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.