diff options
author | Cole Faust <colefaust@google.com> | 2021-10-25 13:29:15 -0700 |
---|---|---|
committer | Cole Faust <colefaust@google.com> | 2021-10-25 13:43:48 -0700 |
commit | 3e1923867a84d40fd01318a059c1dcc495f936cd (patch) | |
tree | 972235804a2ca21eaeeab53ff081aee286ce0325 | |
parent | 3bd9c7d36a1a9e6498558ee33df09176eb3237ad (diff) | |
download | build-3e1923867a84d40fd01318a059c1dcc495f936cd.tar.gz |
Support -s in installmod command
The -s flag must be passed before the adb command,
as in `adb -s emulator-5554 install myapp.apk`
instead of `adb install -s emulator-5554 myapp.apk`.
Parse it and move it to the correct location if it
exists.
Test: Manually
Change-Id: I4b296d7fe4efbe3b25d21d33a8082b321787651a
-rw-r--r-- | envsetup.sh | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/envsetup.sh b/envsetup.sh index b5dc847853..4301d73f0c 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -1459,7 +1459,7 @@ function refreshmod() { > $ANDROID_PRODUCT_OUT/module-info.json.build.log 2>&1 } -# Verifies that module-info.txt exists, creating it if it doesn't. +# Verifies that module-info.txt exists, returning nonzero if it doesn't. function verifymodinfo() { if [ ! "$ANDROID_PRODUCT_OUT" ]; then if [ "$QUIET_VERIFYMODINFO" != "true" ] ; then @@ -1470,7 +1470,7 @@ function verifymodinfo() { if [ ! -f "$ANDROID_PRODUCT_OUT/module-info.json" ]; then if [ "$QUIET_VERIFYMODINFO" != "true" ] ; then - echo "Could not find module-info.json. It will only be built once, and it can be updated with 'refreshmod'" >&2 + echo "Could not find module-info.json. Please run 'refreshmod' first." >&2 fi return 1 fi @@ -1589,6 +1589,10 @@ for output in module_info[module]['installed']: function installmod() { if [[ $# -eq 0 ]]; then echo "usage: installmod [adb install arguments] <module>" >&2 + echo "" >&2 + echo "Only flags to be passed after the \"install\" in adb install are supported," >&2 + echo "with the exception of -s. If -s is passed it will be placed before the \"install\"." >&2 + echo "-s must be the first flag passed if it exists." >&2 return 1 fi @@ -1603,9 +1607,18 @@ function installmod() { echo "Module '$1' does not produce a file ending with .apk (try 'refreshmod' if there have been build changes?)" >&2 return 1 fi + local serial_device="" + if [[ "$1" == "-s" ]]; then + if [[ $# -le 2 ]]; then + echo "-s requires an argument" >&2 + return 1 + fi + serial_device="-s $2" + shift 2 + fi local length=$(( $# - 1 )) - echo adb install ${@:1:$length} $_path - adb install ${@:1:$length} $_path + echo adb $serial_device install ${@:1:$length} $_path + adb $serial_device install ${@:1:$length} $_path } function _complete_android_module_names() { |