Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ffd29aa authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "startop: app_startup script fixes for youtube/chrome"

parents cbf34a23 973a2dcd
Loading
Loading
Loading
Loading
+3 −33
Original line number Diff line number Diff line
@@ -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"
+6 −0
Original line number Diff line number Diff line
@@ -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
+39 −0
Original line number Diff line number Diff line
@@ -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"
}
+0 −17
Original line number Diff line number Diff line
@@ -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