Android O SDK.
[android_tools.git] / sdk / tools / bin / uiautomatorviewer
blob603d982a4a491d6a974550a607caefdccae2b905
1 #!/bin/bash
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.
19 prog="$0"
20 while [ -h "${prog}" ]; do
21 newProg=`/bin/ls -ld "${prog}"`
22 newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
23 if expr "x${newProg}" : 'x/' >/dev/null; then
24 prog="${newProg}"
25 else
26 progdir=`dirname "${prog}"`
27 prog="${progdir}/${newProg}"
29 done
30 oldwd=`pwd`
31 progdir=`dirname "${prog}"`
32 progname=`basename "${prog}"`
33 cd "${progdir}/.."
34 progdir=`pwd`
35 prog="${progdir}"/bin/"${progname}"
36 cd "${oldwd}"
38 jarfile=`basename $APP_HOME/lib/uiautomatorviewer-25.3.2.jar`
39 frameworkdir="$progdir"
40 libdir="$progdir"
41 if [ ! -r "$frameworkdir/$jarfile" ]
42 then
43 frameworkdir=`dirname "$progdir"`/tools/lib
44 libdir=`dirname "$progdir"`/tools/lib
46 if [ ! -r "$frameworkdir/$jarfile" ]
47 then
48 frameworkdir=`dirname "$progdir"`/framework
49 libdir=`dirname "$progdir"`/lib
51 if [ ! -r "$frameworkdir/$jarfile" ]
52 then
53 echo "${progname}: can't find $jarfile"
54 exit 1
57 javaCmd="java"
59 os=`uname`
60 if [ $os == 'Darwin' ]; then
61 javaOpts="-Xmx1600M -XstartOnFirstThread"
62 else
63 javaOpts="-Xmx1600M"
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}"
73 shift
74 done
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/
82 swtpath=""
83 if [ -n "$ANDROID_SWT" ]; then
84 swtpath="$ANDROID_SWT"
85 else
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"
90 else
91 swtpath="${frameworkdir}/${vmarch}"
95 # Combine the swtpath and the framework dir path.
96 if [ -d "$swtpath" ]; then
97 frameworkdir="${swtpath}:${frameworkdir}"
98 else
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."
101 exit 1
104 exec "${javaCmd}" $javaOpts -Djava.ext.dirs="$frameworkdir" -Dcom.android.uiautomator.bindir="$progdir" -jar "$jarpath" "$@"