1#!/bin/bash 2# 3# Copyright 2018, The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 18source "$DIR/lib/common" 19 20launch_application_usage() { 21 cat <<EOF 22Usage: $(basename $0) <package> <activity> 23 24 Positional Arguments: 25 <package> package of the app to test 26 <activity> activity to use 27 28 Named Arguments: 29 -h, --help usage information (this) 30EOF 31} 32 33launch_application() { 34 local package="$1" 35 local activity="$2" 36 37 # if there's any $s inside of the activity name, it needs to be escaped to \$. 38 # example '.app.honeycomb.Shell$HomeActivity' 39 # if the $ is not escaped, adb shell will try to evaluate $HomeActivity to a variable. 40 activity=${activity//\$/\\$} 41 42 adb shell am start -S -W "$package"/"$activity" 43 44 # pipe this into 'parse_metrics' to parse the output. 45} 46 47if [[ $# -lt 2 ]]; then 48 launch_application_usage 49 exit 1 50fi 51 52launch_application "$@" 53