diff options
-rwxr-xr-x | startop/scripts/app_startup/force_compiler_filter | 36 | ||||
-rwxr-xr-x | startop/scripts/app_startup/launch_application | 6 | ||||
-rwxr-xr-x | startop/scripts/app_startup/lib/common | 39 | ||||
-rwxr-xr-x | startop/scripts/app_startup/run_app_with_prefetch | 17 |
4 files changed, 48 insertions, 50 deletions
diff --git a/startop/scripts/app_startup/force_compiler_filter b/startop/scripts/app_startup/force_compiler_filter index 78e915bb4d53..08f983d92bea 100755 --- a/startop/scripts/app_startup/force_compiler_filter +++ b/startop/scripts/app_startup/force_compiler_filter @@ -100,36 +100,6 @@ parse_arguments() { fi } -get_activity_name() { - local package="$1" - local action_key="android.intent.action.MAIN:" - - local activity_line="$(adb shell cmd package query-activities --brief -a android.intent.action.MAIN -c android.intent.category.LAUNCHER | grep "$package")" - verbose_print $activity_line - IFS="/" read -a array <<< "$activity_line" - local activity_name="${array[1]}" - echo "$activity_name" - #adb shell am start "$package/$activity_name" -} - -remote_pidof() { - local procname="$1" - adb shell ps | grep "$procname" | awk '{print $2;}' -} - -remote_pkill() { - local procname="$1" - shift - - local the_pids=$(remote_pidof "$procname") - local pid - - for pid in $the_pids; do - verbose_print adb shell kill "$@" "$pid" - adb shell kill "$@" "$pid" - done -} - force_package_compilation() { local arg_compiler_filter="$1" local arg_package="$2" @@ -150,13 +120,13 @@ main() { # screen needs to be unlocked in order to run an app "$DIR"/unlock_screen - am_output="$(adb shell am start -S -W "$package"/"$activity")" + local output=$("$DIR"/launch_application "$package" "$activity") if [[ $? -ne 0 ]]; then - echo "am start failed" >&2 + echo "launching application failed" >&2 exit 1 fi - verbose_print "$am_output" + verbose_print "$output" # give some time for app startup to complete. # this is supposed to be an upper bound for measuring startup time. sleep "$wait_time" diff --git a/startop/scripts/app_startup/launch_application b/startop/scripts/app_startup/launch_application index bc4ec51d6d08..8a68e5016190 100755 --- a/startop/scripts/app_startup/launch_application +++ b/startop/scripts/app_startup/launch_application @@ -20,6 +20,12 @@ source "$DIR/lib/common" launch_application() { local package="$1" local activity="$2" + + # if there's any $s inside of the activity name, it needs to be escaped to \$. + # example '.app.honeycomb.Shell$HomeActivity' + # if the $ is not escaped, adb shell will try to evaluate $HomeActivity to a variable. + activity=${activity//\$/\\$} + local am_output="$(adb shell am start -S -W "$package"/"$activity")" verbose_print adb shell am start -S -W "$package"/"$activity" if [[ $? -ne 0 ]]; then diff --git a/startop/scripts/app_startup/lib/common b/startop/scripts/app_startup/lib/common index 4d5a53e4bb0c..043d8550b64b 100755 --- a/startop/scripts/app_startup/lib/common +++ b/startop/scripts/app_startup/lib/common @@ -12,3 +12,42 @@ verbose_print() { echo "$@" >&2 fi } + +remote_pidof() { + local procname="$1" + adb shell ps | grep "$procname" | awk '{print $2;}' +} + +remote_pkill() { + local procname="$1" + shift + + local the_pids=$(remote_pidof "$procname") + local pid + + for pid in $the_pids; do + verbose_print adb shell kill "$@" "$pid" + adb shell kill "$@" "$pid" + done +} + +get_activity_name() { + local package="$1" + local action_key="android.intent.action.MAIN:" + + # Example query-activities output being parsed: + # + # Activity #14: + # priority=0 preferredOrder=0 match=0x108000 specificIndex=-1 isDefault=true + # com.google.android.videos/com.google.android.youtube.videos.EntryPoint + # Activity #15: + # priority=0 preferredOrder=0 match=0x108000 specificIndex=-1 isDefault=true + # com.google.android.youtube/.app.honeycomb.Shell$HomeActivity + + # Given package 'com.google.android.youtube' return '.app.honeycomb.Shell$HomeActivity' + + local activity_line="$(adb shell cmd package query-activities --brief -a android.intent.action.MAIN -c android.intent.category.LAUNCHER | grep "$package/")" + IFS="/" read -a array <<< "$activity_line" + local activity_name="${array[1]}" + echo "$activity_name" +} diff --git a/startop/scripts/app_startup/run_app_with_prefetch b/startop/scripts/app_startup/run_app_with_prefetch index ce63ff958613..56bffa85eb90 100755 --- a/startop/scripts/app_startup/run_app_with_prefetch +++ b/startop/scripts/app_startup/run_app_with_prefetch @@ -111,18 +111,6 @@ echo_to_output_file() { echo "$@" } -get_activity_name() { - local package="$1" - local action_key="android.intent.action.MAIN:" - - local activity_line="$(adb shell cmd package query-activities --brief -a android.intent.action.MAIN -c android.intent.category.LAUNCHER | grep "$package")" - #echo $activity_line - IFS="/" read -a array <<< "$activity_line" - local activity_name="${array[1]}" - echo "$activity_name" - #adb shell am start "$package/$activity_name" -} - find_package_path() { local pkg="$1" @@ -133,11 +121,6 @@ find_package_path() { echo "$res" } -remote_pkill() { - local what="$1" - adb shell "for i in $(pid $what); do kill \$i; done" -} - # Main entry point if [[ $# -eq 0 ]]; then usage |