/** Get an {@link com.android.ddmlib.AndroidDebugBridge} instance given an SDK path. */ public static AndroidDebugBridge initAdb(File sdk, Duration timeOut) { AndroidDebugBridge.initIfNeeded(false); File adbPath = FileUtils.getFile(sdk, "platform-tools", "adb"); AndroidDebugBridge adb = AndroidDebugBridge.createBridge(adbPath.getAbsolutePath(), false); waitForAdb(adb, timeOut); return adb; }
/** * Initializes ADB server, optionally restarting it if it points at a different location. * * <p>Can be called multiple times. * * @param pathToAdb location of the ADB server to start. */ @Override public synchronized void init(Path pathToAdb) { checkState(state != State.CLOSED, "Android Debug Bridge has been closed."); if (state.equals(State.INITIALIZED)) { checkState( pathToAdb.equals(this.pathToAdb), "Re-initializing DdmlibAdbServer with a different ADB path. Expected: '%s', got '%s'.", this.pathToAdb, pathToAdb); return; } AndroidDebugBridge.initIfNeeded(/* clientSupport= */ false); this.adb = AndroidDebugBridge.createBridge(pathToAdb.toString(), /* forceNewBridge= */ false); if (adb == null) { throw new CommandExecutionException("Failed to start ADB server."); } this.pathToAdb = pathToAdb; this.state = State.INITIALIZED; }
@Override public void connect() throws AndroidExecutionException { logger.info("Connecting to the Android Debug Bridge at " + adbLocation.getAbsolutePath() + " forceNewBridge = " + forceNewBridge); AndroidDebugBridge.initIfNeeded(true); this.delegate = AndroidDebugBridge.createBridge(adbLocation.getAbsolutePath(), forceNewBridge); waitUntilConnected(); waitForInitialDeviceList(); }
private static void setupBridge(Project project) { AndroidDebugBridge.initIfNeeded(false); String adbPath = ((BaseExtension)project.getExtensions().getByName("android")).getAdbExecutable().getAbsolutePath(); bridge = AndroidDebugBridge.createBridge(adbPath, false); }
public static AndroidDebugBridge startAdb(String adbExe, final DeviceListener listner) { try { Runtime.getRuntime().exec(adbExe + " start-server"); } catch (IOException ex) { LLog.i(ex + ", env has no adb"); } AndroidDebugBridge.initIfNeeded(); final AndroidDebugBridge bridge = AndroidDebugBridge.createBridge(); if (listner != null) { AndroidDebugBridge.addDeviceChangeListener(listner); } return bridge; }
/** Get an {@link com.android.ddmlib.AndroidDebugBridge} instance given an SDK path. */ public static AndroidDebugBridge initAdb(File sdk, Duration timeOut) { AndroidDebugBridge.initIfNeeded(false); File adbPath = FileUtils.getFile(sdk, "platform-tools", "adb"); AndroidDebugBridge adb = AndroidDebugBridge.createBridge(adbPath.getAbsolutePath(), false); waitForAdb(adb, timeOut); return adb; }
@Override public void connect() throws AndroidExecutionException { logger.info("Connecting to the Android Debug Bridge at " + adbLocation.getAbsolutePath() + " forceNewBridge = " + forceNewBridge); DdmPreferences.setTimeOut(ddmsTimeOut); AndroidDebugBridge.initIfNeeded(false); this.delegate = AndroidDebugBridge.createBridge(adbLocation.getAbsolutePath(), forceNewBridge); waitUntilConnected(); waitForInitialDeviceList(); }
@VisibleForTesting AndroidDebugBridge createAndroidDebugBridge() { AndroidDebugBridge.initIfNeeded(false); if (hasAdbPathFilled()) { return AndroidDebugBridge.createBridge(adbPath, false); } return AndroidDebugBridge.createBridge(); }
public Adb(File sdk) { AndroidDebugBridge.initIfNeeded(false /*clientSupport*/); File adbPath = FileUtils.getFile(sdk, "platform-tools", "adb"); bridge = AndroidDebugBridge.createBridge(adbPath.getAbsolutePath(), false /*forceNewBridge*/); long timeOut = 30000; // 30 sec int sleepTime = 1000; while (!bridge.hasInitialDeviceList() && timeOut > 0) { sleep(sleepTime); timeOut -= sleepTime; } if (timeOut <= 0 && !bridge.hasInitialDeviceList()) { throw new RuntimeException("Timeout getting device list.", null); } }
AndroidDebugBridge.initIfNeeded(false /*clientSupport*/);
@Override public void init() throws DeviceException { AndroidDebugBridge.initIfNeeded(false /*clientSupport*/);