1

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

1 Answer 1

2

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
  scriptname="${OUTDIR}/deadReceivers.sh"
  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=${pkg//[$'\t\r\n']}
    pkg=${pkg##*:}
    [[ "${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=${myline//[$'\t\r\n']}
        [[ "${myline}" = "disabledComponents:" || "${myline}" = "enabledComponents:" ]] && continue
        echo "adb ${ADBOPTS} shell \"pm disable ${pkg}/${myline}\"" >> "${scriptname}"
      done
    fi
  done

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
  • 1
    nice Adebar and IzzyOnDroid!
    – rnd_nr_gen
    Apr 15, 2018 at 6:48

You must log in to answer this question.

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