From d7d57142ccb2cd4f4243b36ea42ce433a9ae7bd1 Mon Sep 17 00:00:00 2001 From: Yongqin Liu Date: Tue, 24 Sep 2013 17:39:19 +0800 Subject: build_ddmlib.sh: add script used for building the ddmlib-prebuilt.jar add this script for building the ddmlib-prebuilt.jar used for CTS test. we may do some changes on the ddmlib-prebuilt.jar when run the CTS test on emulators also put the two patches for android-4.3_r2 here Change-Id: Ic147892858d0d4e8a4606021c6150f79363181b0 Signed-off-by: Yongqin Liu --- ...ce.java-change-the-INSTALL_TIMEOUT-to-20-.patch | 30 ++++++ ...teAndroidTestRunner.java-increase-the-tim.patch | 43 +++++++++ ddmlib/build_ddmlib.sh | 104 +++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 ddmlib/0001-ddmlib-Device.java-change-the-INSTALL_TIMEOUT-to-20-.patch create mode 100644 ddmlib/0002-ddmlib-RemoteAndroidTestRunner.java-increase-the-tim.patch create mode 100755 ddmlib/build_ddmlib.sh diff --git a/ddmlib/0001-ddmlib-Device.java-change-the-INSTALL_TIMEOUT-to-20-.patch b/ddmlib/0001-ddmlib-Device.java-change-the-INSTALL_TIMEOUT-to-20-.patch new file mode 100644 index 0000000..9aa56b8 --- /dev/null +++ b/ddmlib/0001-ddmlib-Device.java-change-the-INSTALL_TIMEOUT-to-20-.patch @@ -0,0 +1,30 @@ +From b6208abb29031d5026376eea813e828249b1c0b2 Mon Sep 17 00:00:00 2001 +From: Yongqin Liu +Date: Tue, 24 Sep 2013 17:46:59 +0800 +Subject: [PATCH 1/2] ddmlib Device.java: change the INSTALL_TIMEOUT to 20 + minutes + +By increasing the INSTALL_TIMEOUT to 20 mintues, we can avoid the +timeout when install CTS apk files to emulator device + +Signed-off-by: Yongqin Liu +--- + ddmlib/src/main/java/com/android/ddmlib/Device.java | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ddmlib/src/main/java/com/android/ddmlib/Device.java b/ddmlib/src/main/java/com/android/ddmlib/Device.java +index 55d285d..fe2a1c8 100644 +--- a/ddmlib/src/main/java/com/android/ddmlib/Device.java ++++ b/ddmlib/src/main/java/com/android/ddmlib/Device.java +@@ -39,7 +39,7 @@ import java.util.regex.Pattern; + */ + final class Device implements IDevice { + +- private static final int INSTALL_TIMEOUT = 2*60*1000; //2min ++ private static final int INSTALL_TIMEOUT = 20*60*1000; //20min + private static final int BATTERY_TIMEOUT = 2*1000; //2 seconds + private static final int GETPROP_TIMEOUT = 2*1000; //2 seconds + +-- +1.8.1.2 + diff --git a/ddmlib/0002-ddmlib-RemoteAndroidTestRunner.java-increase-the-tim.patch b/ddmlib/0002-ddmlib-RemoteAndroidTestRunner.java-increase-the-tim.patch new file mode 100644 index 0000000..ce975f1 --- /dev/null +++ b/ddmlib/0002-ddmlib-RemoteAndroidTestRunner.java-increase-the-tim.patch @@ -0,0 +1,43 @@ +From cee5882ac37a268b8118737116aae85803c3d407 Mon Sep 17 00:00:00 2001 +From: Yongqin Liu +Date: Tue, 24 Sep 2013 21:30:02 +0800 +Subject: [PATCH 2/2] ddmlib RemoteAndroidTestRunner.java: increase the timeout + value for test case to 100 min + +set the time out value to 100 minutes by default. +if the specified value bigger that 100 minutes, then use that value. +if the specified value is 0 which mean no time out, then set it to 0 as it is +otherwise set it to 100 minutes so that it will wait for the test run +completion and will not cause the reboot problem. + +Signed-off-by: Yongqin Liu +--- + .../android/ddmlib/testrunner/RemoteAndroidTestRunner.java | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/ddmlib/src/main/java/com/android/ddmlib/testrunner/RemoteAndroidTestRunner.java b/ddmlib/src/main/java/com/android/ddmlib/testrunner/RemoteAndroidTestRunner.java +index 9897fcd..5791298 100644 +--- a/ddmlib/src/main/java/com/android/ddmlib/testrunner/RemoteAndroidTestRunner.java ++++ b/ddmlib/src/main/java/com/android/ddmlib/testrunner/RemoteAndroidTestRunner.java +@@ -181,7 +181,17 @@ public class RemoteAndroidTestRunner implements IRemoteAndroidTestRunner { + + @Override + public void setMaxtimeToOutputResponse(int maxTimeToOutputResponse) { +- mMaxTimeToOutputResponse = maxTimeToOutputResponse; ++ // when small than 100 minutes, set to 100 minutes, ++ // when bigger than 100 minutes, set to the passed value ++ // but when 0 is passed, then set it to 0 ++ int timeout = 100 * 60 * 1000; ++ if (maxTimeToOutputResponse == 0){ ++ mMaxTimeToOutputResponse = 0; ++ }else if (maxTimeToOutputResponse <= timeout){ ++ mMaxTimeToOutputResponse = timeout; ++ }else{ ++ mMaxTimeToOutputResponse = maxTimeToOutputResponse; ++ } + } + + @Override +-- +1.8.1.2 + diff --git a/ddmlib/build_ddmlib.sh b/ddmlib/build_ddmlib.sh new file mode 100755 index 0000000..67a26dd --- /dev/null +++ b/ddmlib/build_ddmlib.sh @@ -0,0 +1,104 @@ +#!/bin/bash + +export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64/ +CUR_DIR=$(pwd) +link_src=$(readlink $0) +if [ -z "${link_src}" ]; then + PARENT=$(cd $(dirname $0); pwd) +else + PARENT=$(cd $(dirname ${link_src}); pwd) +fi + +function getTop(){ + local parent_dir=$1 + if [ -z "${parent_dir}" ] || [ "X${parent_dir}" == "X/" ]; then + return + fi + if [ -f "${parent_dir}/build/envsetup.sh" ]; then + echo "${parent_dir}" + return + fi + local new_parent=$(cd $(dirname ${parent_dir}); pwd) + getTop "${new_parent}" +} + +function clone_master(){ + ## clone the tools/external/gradle repository which will be used to compile the ddmlib jar file + clone=true + gradle_dir="${tools_dir}/external/gradle" + if [ -d "${gradle_dir}" ]; then + cd ${gradle_dir} + git status &>/dev/null + if [ $? -eq 0 ]; then + clone=false + fi + fi + if ${clone}; then + rm -fr ${gradle_dir} + cd $(dirname ${gradle_dir}) + git clone https://android.googlesource.com/platform/tools/external/gradle + fi + + ## clone the tools/base repository which includes the ddmlib source + clone=true + base_dir="${tools_dir}/base" + if [ -d "${base_dir}" ]; then + cd ${base_dir} + git status &>/dev/null + if [ $? -eq 0 ]; then + clone=false + fi + fi + if ${clone}; then + rm -fr ${base_dir} + cd $(dirname ${base_dir}) + git clone https://android.googlesource.com/platform/tools/base + fi +} + + +function patch_4.3_r2(){ + cd ${tools_dir}/base/ + git checkout -b android-4.3_r2 android-4.3_r2 + ## apply patch for Device.java for INSTALL_TIMEOUT + patch_f="${PARENT}/0001-ddmlib-Device.java-change-the-INSTALL_TIMEOUT-to-20-.patch" + git am ${patch_f} + if [ $? -ne 0 ]; then + echo "Failed to apply the patch: ${patch_f}" + exit 1 + fi + + ## apply patch for RemoteAndroidTestRunner.java for max output response timeout + patch_f="${PARENT}/0002-ddmlib-RemoteAndroidTestRunner.java-increase-the-tim.patch" + git am ${patch_f} + if [ $? -ne 0 ]; then + echo "Failed to apply the patch: ${patch_f}" + exit 1 + fi +} + +function main(){ + root_dir=$(getTop ${PARENT}) + if [ -z "${root_dir}" ]; then + echo "Failed to find root directory, please put this script under the root directory of android source" + exit 1 + fi + rm -fr ${root_dir}/out/host/gradle/ + tools_dir="${root_dir}/tools/" + + clone_master + patch_4.3_r2 + + ## compile the ddmlib jar file + cd ${tools_dir}/base/ + ./gradlew :ddmlib:build + + ddmlib=$(find ${root_dir}/out/host/ -name ddmlib*.jar ! -name *sources.jar ! -name *javadoc.jar) + if [ -z "$ddmlib" ]; then + echo "Failed to compile the ddmlib jar file" + exit 1 + fi + cp ${ddmlib} ${CUR_DIR}/ddmlib-prebuilt.jar + echo "The generated ddmlib jar file is: ${CUR_DIR}/ddmlib-prebuilt.jar" +} +main "$@" -- cgit v1.2.3