当前位置: 首页>>代码示例>>Java>>正文


Java AndroidDebugBridge.initIfNeeded方法代码示例

本文整理汇总了Java中com.android.ddmlib.AndroidDebugBridge.initIfNeeded方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidDebugBridge.initIfNeeded方法的具体用法?Java AndroidDebugBridge.initIfNeeded怎么用?Java AndroidDebugBridge.initIfNeeded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.ddmlib.AndroidDebugBridge的用法示例。


在下文中一共展示了AndroidDebugBridge.initIfNeeded方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateAdb

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
protected void updateAdb() {
    AndroidSdk sdk = defaultSdk.get();
    if (sdk != null) {
        final FileObject path = sdk.findTool(ADB_TOOL);
        if (path != null) {
            ClientData.class.getClassLoader().clearAssertionStatus();      //qattern
            DebugPortManager.setProvider(DebugPortProvider.getDefault());
            AndroidDebugBridge.initIfNeeded(true);
            String adbLocation = FileUtil.toFile(path).getAbsolutePath();
            String lastLocation = adbPath.getAndSet(adbLocation);
            pcs.firePropertyChange(PROP_DEFAULT_ADB_PATH, lastLocation, adbLocation);
            AndroidDebugBridge bridge = AndroidDebugBridge.createBridge(adbLocation, false);
            AndroidDebugBridge lastAdb = adb.getAndSet(bridge);
            pcs.firePropertyChange(PROP_DEFAULT_ADB, lastAdb, bridge);
        }
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:18,代码来源:AndroidSdkProvider.java

示例2: createAdb

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
 * Creates connection to adb and waits for this connection to be initialized and receive initial
 * list of devices.
 */
@Nullable
@SuppressWarnings("PMD.EmptyCatchBlock")
private AndroidDebugBridge createAdb() throws InterruptedException {
  AndroidDebugBridge.initIfNeeded(/* clientSupport */ false);
  AndroidDebugBridge adb = AndroidDebugBridge.createBridge(this.adbExecutablePath, false);
  if (adb == null) {
    System.err.println("Failed to connect to adb. Make sure adb server is running.");
    return null;
  }

  long start = System.currentTimeMillis();
  while (!isAdbInitialized(adb)) {
    long timeLeft = start + ADB_CONNECT_TIMEOUT_MS - System.currentTimeMillis();
    if (timeLeft <= 0) {
      break;
    }
    Thread.sleep(ADB_CONNECT_TIME_STEP_MS);
  }
  return isAdbInitialized(adb) ? adb : null;
}
 
开发者ID:facebook,项目名称:buck,代码行数:25,代码来源:InstrumentationTestRunner.java

示例3: init

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
public static void init() throws InterruptedException {
  if (AndroidDebugBridge.getBridge() == null
      || !isAdbInitialized(AndroidDebugBridge.getBridge())) {
    AndroidDebugBridge.initIfNeeded(/* clientSupport */ true);
    AndroidDebugBridge.createBridge(
        BuckSettingsProvider.getInstance().resolveAdbExecutable(), false);
  }

  long start = System.currentTimeMillis();
  while (!isAdbInitialized(AndroidDebugBridge.getBridge())) {
    long timeLeft = start + ADB_CONNECT_TIMEOUT_MS - System.currentTimeMillis();
    if (timeLeft <= 0) {
      break;
    }
    Thread.sleep(ADB_CONNECT_TIME_STEP_MS);
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:18,代码来源:AndroidDebugger.java

示例4: initializeADBConnection

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
 * Initializes the AndroidDebugBridge and registers the TestDeviceManager
 * with the AndroidDebugBridge device change listener. It is recommended
 * that addConnectionListener(TestDeviceConnectionListener) be called with 
 * all listeners before calling this method.
 */
public void initializeADBConnection() {
	
	// Get a device bridge instance. Initialize, create and restart.
	try {
		AndroidDebugBridge.initIfNeeded(false);
	} catch (IllegalStateException ise) {
		ise.printStackTrace();
		System.out.println("The IllegalStateException is not a show " +
		"stopper. It has been handled. This is just debug spew." +
		" Please proceed.");
	}
	bridge = AndroidDebugBridge.getBridge();
	
	if (bridge == null) {		
		bridge = AndroidDebugBridge.createBridge(
                adbPath, 
                false);
	}
	
	// Add the existing devices to the list of devices we are tracking.
	if (bridge.isConnected() && bridge.hasInitialDeviceList()) {
		IDevice[] connectedDevices = bridge.getDevices();
		
		for (int i = 0; i < connectedDevices.length; i++) {
			TestDevice tDevice = new TestDevice(connectedDevices[i]);
			
			devices.add(tDevice);
			notifyListenersAddedDevice(tDevice);
		}
	}
       
       AndroidDebugBridge.addDeviceChangeListener(this);
}
 
开发者ID:eBay,项目名称:mtdtool,代码行数:40,代码来源:TestDeviceManager.java

示例5: init

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
@Override
public void init() throws DeviceException {
    AndroidDebugBridge.initIfNeeded(false /*clientSupport*/);

    bridge = AndroidDebugBridge.createBridge(
            adbExe, false /*forceNewBridge*/);

    if (bridge == null) {
        throw new RuntimeException("Unable to connect to adb");
    }
}
 
开发者ID:manymo,项目名称:AndroidBuildSystemPlugin,代码行数:12,代码来源:ManymoDeviceProvider.java

示例6: initAdb

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
public static AndroidDebugBridge initAdb() {
    File adbFile = SdkHelper.getAdb();
    AndroidDebugBridge.initIfNeeded(false);
    return AndroidDebugBridge.createBridge(adbFile.getAbsolutePath(), false);
}
 
开发者ID:apptik,项目名称:tarator,代码行数:6,代码来源:Nuts.java

示例7: init

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
@Override
public void init() throws DeviceException {
    AndroidDebugBridge.initIfNeeded(false /*clientSupport*/);

    AndroidDebugBridge bridge = AndroidDebugBridge.createBridge(
            adbLocation.getAbsolutePath(), false /*forceNewBridge*/);

    long timeOut = 30000; // 30 sec
    int sleepTime = 1000;
    while (!bridge.hasInitialDeviceList() && timeOut > 0) {
        try {
            Thread.sleep(sleepTime);
        } catch (InterruptedException e) {
            throw new DeviceException(e);
        }
        timeOut -= sleepTime;
    }

    if (timeOut <= 0 && !bridge.hasInitialDeviceList()) {
        throw new DeviceException("Timeout getting device list.");
    }

    IDevice[] devices = bridge.getDevices();

    if (devices.length == 0) {
        throw new DeviceException("No connected devices!");
    }

    final String androidSerial = System.getenv("ANDROID_SERIAL");
    final Boolean isValidSerial = androidSerial != null && !androidSerial.isEmpty();
    final List<IDevice> filteredDevices = Lists.newArrayListWithCapacity(devices.length);
    for (IDevice iDevice : devices) {
        if (!isValidSerial || iDevice.getSerialNumber().equals(androidSerial)) {
            filteredDevices.add(iDevice);
        }
    }

    if (filteredDevices.isEmpty()) {
        throw new DeviceException(String.format(
                "Connected device with serial %s not found!", androidSerial));
    }

    for (IDevice device : filteredDevices) {
        if (device.getState() == IDevice.DeviceState.ONLINE) {
            localDevices.add(new ConnectedDevice(device));
        } else {
            iLogger.info(
                    "Skipping device '%s' (%s): Device is %s%s.",
                    device.getName(), device.getSerialNumber(), device.getState(),
                    device.getState() == IDevice.DeviceState.UNAUTHORIZED ? ",\n"
                            + "    see http://d.android.com/tools/help/adb.html#Enabling" : "");
        }
    }

    if (localDevices.isEmpty()) {
        if (isValidSerial) {
            throw new DeviceException(String.format(
                    "Connected device with serial $1%s is not online.",
                    androidSerial));
        } else {
            throw new DeviceException("No online devices found.");
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:65,代码来源:ConnectedDeviceProvider.java


注:本文中的com.android.ddmlib.AndroidDebugBridge.initIfNeeded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。