aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2015-10-03 00:43:18 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-10-03 00:43:18 +0000
commite8826f6285217ccf821563f4bf3546c7d230e1c4 (patch)
tree0f0500505d8dc54e1edd2907bf8db405041dedfe
parent5dedc1647b3c85c7eaaaab8e30e585e3f1d9e64b (diff)
parentf5fb02509c6c2f732618e7acb1aa33dc5f8c45ff (diff)
downloadplatform_sdk-e8826f6285217ccf821563f4bf3546c7d230e1c4.tar.gz
platform_sdk-e8826f6285217ccf821563f4bf3546c7d230e1c4.tar.bz2
platform_sdk-e8826f6285217ccf821563f4bf3546c7d230e1c4.zip
am f5fb0250: Merge "Complete subcommands for dumpsys, am and pm."
* commit 'f5fb02509c6c2f732618e7acb1aa33dc5f8c45ff': Complete subcommands for dumpsys, am and pm.
-rw-r--r--bash_completion/adb.bash116
1 files changed, 103 insertions, 13 deletions
diff --git a/bash_completion/adb.bash b/bash_completion/adb.bash
index 397de8e4b..f5c710579 100644
--- a/bash_completion/adb.bash
+++ b/bash_completion/adb.bash
@@ -210,6 +210,15 @@ _adb_cmd_shell() {
ls)
_adb_shell_ls $serial $i
;;
+ dumpsys)
+ _adb_cmd_shell_dumpsys "$serial" $i
+ ;;
+ am)
+ _adb_cmd_shell_am "$serial" $i
+ ;;
+ pm)
+ _adb_cmd_shell_pm "$serial" $i
+ ;;
/*)
_adb_util_list_files $serial "$cur"
;;
@@ -221,6 +230,81 @@ _adb_cmd_shell() {
return 0
}
+_adb_cmd_shell_dumpsys() {
+ local serial i cur
+ local -a args
+ local candidates
+
+ unset IFS
+
+ serial=$1
+ i=$2
+
+ if [ "$serial" != "none" ]; then
+ args=(-s $serial)
+ fi
+
+ if (( $i == $COMP_CWORD )) ; then
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ # First line is a header, so need "1d".
+ candidates=$(command adb ${args[@]} shell dumpsys -l 2> /dev/null | sed -e '1d;s/^ *//' | tr -d '\r')
+ candidates="-l $candidates"
+ COMPREPLY=( $(compgen -W "$candidates" -- "$cur") )
+ return 0
+ fi
+
+ COMPREPLY=( )
+ return 0
+}
+
+_adb_cmd_shell_am() {
+ local serial i cur
+ local candidates
+
+ unset IFS
+
+ serial=$1
+ i=$2
+
+ if (( $i == $COMP_CWORD )) ; then
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ candidates="broadcast clear-debug-app clear-watch-heap dumpheap force-stop get-config get-inactive hang idle-maintenance instrument kill kill-all monitor package-importance profile restart screen-compat send-trim-memory set-debug-app set-inactive set-watch-heap stack start startservice start-user stopservice stop-user suppress-resize-config-changes switch-user task to-app-uri to-intent-uri to-uri"
+ COMPREPLY=( $(compgen -W "$candidates" -- "$cur") )
+ return 0
+ fi
+
+ COMPREPLY=( )
+ return 0
+}
+
+
+_adb_cmd_shell_pm() {
+ local serial i cur
+ local candidates
+
+ unset IFS
+
+ serial=$1
+ i=$2
+
+ if (( $i == $COMP_CWORD )) ; then
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ candidates="-l -lf -p clear create-user default-state disable disable-until-used disable-user dump enable get-app-link get-install-location get-max-users grant hide install install-abandon install-commit install-create install-write list move-package move-primary-storage path remove-user reset-permissions revoke set-app-link set-installer set-install-location set-permission-enforced trim-caches unhide uninstall"
+ COMPREPLY=( $(compgen -W "$candidates" -- "$cur") )
+ return 0
+ fi
+
+ if (( $i + 1 == $COMP_CWORD )) && [[ "${COMP_WORDS[COMP_CWORD -1]}" == "list" ]] ; then
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ candidates="packages permission-groups permissions instrumentation features libraries users"
+ COMPREPLY=( $(compgen -W "$candidates" -- "$cur") )
+ return 0
+ fi
+
+ COMPREPLY=( )
+ return 0
+}
+
_adb_cmd_uninstall() {
local serial i where cur packages
@@ -315,19 +399,25 @@ _adb_util_list_files() {
args=(-s $serial)
fi
- toks=( ${toks[@]-} $(
- command adb ${args[@]} shell ls -dF ${file}"*" '2>' /dev/null 2> /dev/null | tr -d '\r' | {
- while read -r tmp; do
- filetype=${tmp%% *}
- filename=${tmp:${#filetype}+1}
- if [[ ${filetype:${#filetype}-1:1} == d ]]; then
- printf '%s/\n' "$filename"
- else
- printf '%s\n' "$filename"
- fi
- done
- }
- ))
+ if [[ $( command adb ${args[@]} shell ls -dF / '2>/dev/null' | tr -d '\r' ) == "d /" ]] ; then
+ toks=( ${toks[@]-} $(
+ command adb ${args[@]} shell ls -dF ${file}"*" '2>' /dev/null 2> /dev/null | tr -d '\r' | {
+ while read -r tmp; do
+ filetype=${tmp%% *}
+ filename=${tmp:${#filetype}+1}
+ if [[ ${filetype:${#filetype}-1:1} == d ]]; then
+ printf '%s/\n' "$filename"
+ else
+ printf '%s\n' "$filename"
+ fi
+ done
+ }
+ ))
+ else
+ toks=( ${toks[@]-} $(
+ command adb ${args[@]} shell ls -dp ${file}"*" '2>/dev/null' 2> /dev/null | tr -d '\r'
+ ))
+ fi
# Since we're probably doing file completion here, don't add a space after.
if [[ $(type -t compopt) = "builtin" ]]; then