private static void doInitializeDdmlib(@NotNull String adbPath) { synchronized (myDdmsLock) { if (!myDdmLibInitialized) { myDdmLibInitialized = true; DdmPreferences.setLogLevel(Log.LogLevel.INFO.getStringValue()); DdmPreferences.setTimeOut(AndroidUtils.TIMEOUT); AndroidDebugBridge.init(AndroidEnableAdbServiceAction.isAdbServiceEnabled()); LOG.info("DDMLib initialized"); final AndroidDebugBridge bridge = AndroidDebugBridge.createBridge(adbPath, true); waitUntilConnect(bridge); if (!bridge.isConnected()) { LOG.info("Failed to connect debug bridge"); } } else { final AndroidDebugBridge bridge = AndroidDebugBridge.getBridge(); final boolean forceRestart = myAdbCrashed || (bridge != null && !bridge.isConnected()); if (forceRestart) { LOG.info("Restart debug bridge: " + (myAdbCrashed ? "crashed" : "disconnected")); } final AndroidDebugBridge newBridge = AndroidDebugBridge.createBridge(adbPath, forceRestart); waitUntilConnect(newBridge); if (!newBridge.isConnected()) { LOG.info("Failed to connect debug bridge after restart"); } } } }
public AdbBackend() { // [try to] ensure ADB is running String adbLocation = findAdb(); AndroidDebugBridge.init(false /* debugger support */); bridge = AndroidDebugBridge.createBridge(adbLocation, true /* forceNewBridge */); }
/** * Initialize the Android Debug Bridge and wait for it to start. Does not reinitialize it if it * has already been initialized (that would through and IllegalStateException...). Synchronized * sine the init call in the library is also synchronized .. just in case. * * @return */ protected AndroidDebugBridge initAndroidDebugBridge() throws MojoExecutionException { synchronized (ADB_LOCK) { if (!adbInitialized) { AndroidDebugBridge.init(false); adbInitialized = true; } AndroidDebugBridge androidDebugBridge = AndroidDebugBridge.createBridge(getAndroidSdk().getAdbPath(), false); waitUntilConnected(androidDebugBridge); return androidDebugBridge; } }
/** * Initialize the system object. <br> * Get all the connected devices (if exist), set port forwarding & initialize the TCP connection * <br> */ private AdbController() throws Exception { adbLocation = findAdbFile(); // Init the AndroidDebugBridge object try { AndroidDebugBridge.init(false); } catch (Exception e) { if (e.getMessage() .contains("AndroidDebugBridge.init() has already been called.")) {; // ignore } else { throw e; } } adb = AndroidDebugBridge.createBridge( adbLocation.getAbsolutePath() + File.separator + "adb", true); if (adb == null) { throw new IllegalStateException("Failed to create ADB bridge"); } AndroidDebugBridge.addDeviceChangeListener(this); }
/** {@inheritDoc} */ public void init(boolean clientSupport, String adbOsLocation) { AndroidDebugBridge.init(clientSupport); mAdbBridge = AndroidDebugBridge.createBridge(adbOsLocation, false); }