diff options
author | Xavier Ducrohet <xav@android.com> | 2010-10-20 13:23:41 -0700 |
---|---|---|
committer | Android Code Review <code-review@android.com> | 2010-10-20 13:23:41 -0700 |
commit | f4ca7ef327b0ba465d1f6e42515011edc6bf4517 (patch) | |
tree | 62a1886d4d8266597d67a701dd967958a81865b3 | |
parent | dea7f784656b0d3af46cdcb0c5d514aa25b400c0 (diff) | |
parent | a80e4dc30f8148d09cb46d98465d917bbe81d08f (diff) | |
download | sdk-f4ca7ef327b0ba465d1f6e42515011edc6bf4517.zip sdk-f4ca7ef327b0ba465d1f6e42515011edc6bf4517.tar.gz sdk-f4ca7ef327b0ba465d1f6e42515011edc6bf4517.tar.bz2 |
Merge "Integrate 17398174 into tools_r8. DO NOT MERGE." into tools_r8
-rw-r--r-- | monkeyrunner/etc/monkeyrunner.bat | 2 | ||||
-rw-r--r-- | monkeyrunner/src/Android.mk | 4 | ||||
-rw-r--r-- | monkeyrunner/src/com/android/monkeyrunner/adb/AdbBackend.java | 27 |
3 files changed, 30 insertions, 3 deletions
diff --git a/monkeyrunner/etc/monkeyrunner.bat b/monkeyrunner/etc/monkeyrunner.bat index e927d08..1cf38ca 100644 --- a/monkeyrunner/etc/monkeyrunner.bat +++ b/monkeyrunner/etc/monkeyrunner.bat @@ -43,4 +43,4 @@ if exist %frameworkdir%%jarfile% goto JarFileOk set jarpath=%frameworkdir%%jarfile% -call %java_exe% -Xmx512m -Djava.ext.dirs=%frameworkdir% -jar %jarpath% %* +call %java_exe% -Xmx512m -Djava.ext.dirs=%frameworkdir% -Dcom.android.monkeyrunner.bindir=..\framework -jar %jarpath% %* diff --git a/monkeyrunner/src/Android.mk b/monkeyrunner/src/Android.mk index 11c7cc0..38be272 100644 --- a/monkeyrunner/src/Android.mk +++ b/monkeyrunner/src/Android.mk @@ -23,7 +23,9 @@ LOCAL_JAVA_LIBRARIES := \ ddmlib \ jython \ guavalib \ - jsilver + jsilver \ + sdklib + LOCAL_JAVA_RESOURCE_DIRS := resources LOCAL_MODULE := monkeyrunner diff --git a/monkeyrunner/src/com/android/monkeyrunner/adb/AdbBackend.java b/monkeyrunner/src/com/android/monkeyrunner/adb/AdbBackend.java index b9549a3..455d131 100644 --- a/monkeyrunner/src/com/android/monkeyrunner/adb/AdbBackend.java +++ b/monkeyrunner/src/com/android/monkeyrunner/adb/AdbBackend.java @@ -21,7 +21,9 @@ import com.android.ddmlib.AndroidDebugBridge; import com.android.ddmlib.IDevice; import com.android.monkeyrunner.MonkeyDevice; import com.android.monkeyrunner.MonkeyRunnerBackend; +import com.android.sdklib.SdkConstants; +import java.io.File; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -39,10 +41,33 @@ public class AdbBackend implements MonkeyRunnerBackend { private final AndroidDebugBridge bridge; public AdbBackend() { + // [try to] ensure ADB is running + String adbLocation = findAdb(); + AndroidDebugBridge.init(false /* debugger support */); bridge = AndroidDebugBridge.createBridge( - "adb", true /* forceNewBridge */); + adbLocation, true /* forceNewBridge */); + } + + private String findAdb() { + String mrParentLocation = + System.getProperty("com.android.monkeyrunner.bindir"); //$NON-NLS-1$ + + // in the new SDK, adb is in the platform-tools, but when run from the command line + // in the Android source tree, then adb is next to monkeyrunner. + if (mrParentLocation != null && mrParentLocation.length() != 0) { + // check if there's a platform-tools folder + File platformTools = new File(new File(mrParentLocation).getParent(), + SdkConstants.FD_PLATFORM_TOOLS); + if (platformTools.isDirectory()) { + return platformTools.getAbsolutePath() + File.separator + SdkConstants.FN_ADB; + } + + return mrParentLocation + File.separator + SdkConstants.FN_ADB; + } + + return SdkConstants.FN_ADB; } /** |