3 # Copyright 2012, The Android Open Source Project
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Set up prog to be the path of this script, including following symlinks,
18 # and set up progdir to be the fully-qualified pathname of its directory.
20 while [ -h "${prog}" ]; do
21 newProg
=`/bin/ls -ld "${prog}"`
22 newProg
=`expr "${newProg}" : ".* -> \(.*\)$"`
23 if expr "x${newProg}" : 'x/' >/dev
/null
; then
26 progdir
=`dirname "${prog}"`
27 prog
="${progdir}/${newProg}"
31 progdir
=`dirname "${prog}"`
32 progname
=`basename "${prog}"`
35 prog
="${progdir}"/bin
/"${progname}"
38 jarfile
=`basename $APP_HOME/lib/uiautomatorviewer-25.3.2.jar`
39 frameworkdir
="$progdir"
41 if [ ! -r "$frameworkdir/$jarfile" ]
43 frameworkdir
=`dirname "$progdir"`/tools
/lib
44 libdir
=`dirname "$progdir"`/tools
/lib
46 if [ ! -r "$frameworkdir/$jarfile" ]
48 frameworkdir
=`dirname "$progdir"`/framework
49 libdir
=`dirname "$progdir"`/lib
51 if [ ! -r "$frameworkdir/$jarfile" ]
53 echo "${progname}: can't find $jarfile"
60 if [ $os == 'Darwin' ]; then
61 javaOpts
="-Xmx1600M -XstartOnFirstThread"
66 if [ `uname` = "Linux" ]; then
67 export GDK_NATIVE_WINDOWS
=true
70 while expr "x$1" : 'x-J' >/dev
/null
; do
71 opt
=`expr "x$1" : 'x-J\(.*\)'`
72 javaOpts
="${javaOpts} -${opt}"
76 jarpath
="$frameworkdir/$jarfile"
78 # Figure out the path to the swt.jar for the current architecture.
79 # if ANDROID_SWT is defined, then just use this.
80 # else, if running in the Android source tree, then look for the correct swt folder in prebuilt
81 # else, look for the correct swt folder in the SDK under tools/lib/
83 if [ -n "$ANDROID_SWT" ]; then
84 swtpath
="$ANDROID_SWT"
86 vmarch
=`"${progdir}"/bin/archquery`
87 if [ -n "$ANDROID_BUILD_TOP" ]; then
88 osname
=`uname -s | tr A-Z a-z`
89 swtpath
="${ANDROID_BUILD_TOP}/prebuilts/tools/${osname}-${vmarch}/swt"
91 swtpath
="${frameworkdir}/${vmarch}"
95 # Combine the swtpath and the framework dir path.
96 if [ -d "$swtpath" ]; then
97 frameworkdir
="${swtpath}:${frameworkdir}"
99 echo "SWT folder '${swtpath}' does not exist."
100 echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
104 exec "${javaCmd}" $javaOpts -Djava.ext.
dirs="$frameworkdir" -Dcom.android.uiautomator.bindir
="$progdir" -jar "$jarpath" "$@"