aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul McClave <pmcclave@google.com>2012-10-22 18:19:50 +0200
committerPaul McClave <pmcclave@google.com>2012-10-22 18:19:50 +0200
commit9d567c3de7d18a466e8d77ace93e5247b7af7120 (patch)
tree94fc4b79aa6dfac04356a3b1b74bc829972c67cb
parent7a359895f07d5e6e508bb8b8502f5fd52d69e979 (diff)
downloadsdk-9d567c3de7d18a466e8d77ace93e5247b7af7120.zip
sdk-9d567c3de7d18a466e8d77ace93e5247b7af7120.tar.gz
sdk-9d567c3de7d18a466e8d77ace93e5247b7af7120.tar.bz2
Add option to disable initialization of AndroidDebugBridge.
Change-Id: Iea659ca03c864db79f53154a419d32dece9aba66
-rw-r--r--chimpchat/src/com/android/chimpchat/ChimpChat.java9
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/AdbBackend.java35
2 files changed, 30 insertions, 14 deletions
diff --git a/chimpchat/src/com/android/chimpchat/ChimpChat.java b/chimpchat/src/com/android/chimpchat/ChimpChat.java
index ad9ef0d..5618ec6 100644
--- a/chimpchat/src/com/android/chimpchat/ChimpChat.java
+++ b/chimpchat/src/com/android/chimpchat/ChimpChat.java
@@ -33,6 +33,7 @@ import java.util.TreeMap;
public class ChimpChat {
private final IChimpBackend mBackend;
private static String sAdbLocation;
+ private static boolean sNoInitAdb;
private ChimpChat(IChimpBackend backend) {
this.mBackend = backend;
@@ -45,6 +46,8 @@ public class ChimpChat {
*/
public static ChimpChat getInstance(Map<String, String> options) {
sAdbLocation = options.get("adbLocation");
+ sNoInitAdb = Boolean.valueOf(options.get("noInitAdb"));
+
IChimpBackend backend = createBackendByName(options.get("backend"));
if (backend == null) {
return null;
@@ -72,11 +75,7 @@ public class ChimpChat {
private static IChimpBackend createBackendByName(String backendName) {
if ("adb".equals(backendName)) {
- if (sAdbLocation == null) {
- return new AdbBackend();
- } else {
- return new AdbBackend(sAdbLocation);
- }
+ return new AdbBackend(sAdbLocation, sNoInitAdb);
} else {
return null;
}
diff --git a/chimpchat/src/com/android/chimpchat/adb/AdbBackend.java b/chimpchat/src/com/android/chimpchat/adb/AdbBackend.java
index b4dc233..2cb5be7 100644
--- a/chimpchat/src/com/android/chimpchat/adb/AdbBackend.java
+++ b/chimpchat/src/com/android/chimpchat/adb/AdbBackend.java
@@ -38,23 +38,38 @@ public class AdbBackend implements IChimpBackend {
private static final int CONNECTION_ITERATION_TIMEOUT_MS = 200;
private final List<IChimpDevice> devices = Lists.newArrayList();
private final AndroidDebugBridge bridge;
+ private final boolean initAdb;
+ /**
+ * Constructs an AdbBackend with default options.
+ */
public AdbBackend() {
+ this(null, false);
+ }
+
+ /**
+ * Constructs an AdbBackend.
+ *
+ * @param adbLocation The location of the adb binary. If null, AdbBackend will
+ * attempt to find the binary by itself.
+ * @param noInitAdb If true, AdbBackend will not initialize AndroidDebugBridge.
+ */
+ public AdbBackend(String adbLocation, boolean noInitAdb) {
+ this.initAdb = !noInitAdb;
+
// [try to] ensure ADB is running
- String adbLocation = findAdb();
+ if (adbLocation == null) {
+ adbLocation = findAdb();
+ }
- AndroidDebugBridge.init(false /* debugger support */);
+ if (initAdb) {
+ AndroidDebugBridge.init(false /* debugger support */);
+ }
bridge = AndroidDebugBridge.createBridge(
adbLocation, true /* forceNewBridge */);
}
- public AdbBackend(String location) {
- AndroidDebugBridge.init(false /* debugger support */);
- bridge = AndroidDebugBridge.createBridge(location,
- true /* force new bridge */);
- }
-
private String findAdb() {
String mrParentLocation =
System.getProperty("com.android.monkeyrunner.bindir"); //$NON-NLS-1$
@@ -126,6 +141,8 @@ public class AdbBackend implements IChimpBackend {
for (IChimpDevice device : devices) {
device.dispose();
}
- AndroidDebugBridge.terminate();
+ if (initAdb) {
+ AndroidDebugBridge.terminate();
+ }
}
}