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


Java AndroidDebugBridge.hasInitialDeviceList方法代码示例

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


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

示例1: waitForInitialDeviceList

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
 * Wait for the Android Debug Bridge to return an initial device list.
 */
protected static void waitForInitialDeviceList(final AndroidDebugBridge androidDebugBridge, Logger logger) {
    if (!androidDebugBridge.hasInitialDeviceList()) {
        logger.info("Waiting for initial device list from the Android Debug Bridge");
        long limitTime = System.currentTimeMillis() + ADB_TIMEOUT_MS;
        while (!androidDebugBridge.hasInitialDeviceList() && (System.currentTimeMillis() < limitTime)) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException("Interrupted waiting for initial device list from Android Debug Bridge");
            }
        }
        if (!androidDebugBridge.hasInitialDeviceList()) {
            logger.error("Did not receive initial device list from the Android Debug Bridge.");
        }
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:20,代码来源:AwoInstaller.java

示例2: getDevices

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private IDevice[] getDevices(Project project) {
    List<AndroidFacet> facets = getApplicationFacets(project);
    if (!facets.isEmpty()) {
        AndroidFacet facet;
        if (facets.size() > 1) {
            facet = ModuleChooserDialogHelper.showDialogForFacets(project, facets);
            if (facet == null) {
                return null;
            }
        } else {
            facet = facets.get(0);
        }

        AndroidDebugBridge bridge = facet.getDebugBridge();
        if (bridge == null) {
            log.error("No platform configured");
            return null;
        }

        if (bridge.isConnected() && bridge.hasInitialDeviceList()) {
            return bridge.getDevices();
        }
    }
    return null;
}
 
开发者ID:willowtreeapps,项目名称:resPeeker,代码行数:26,代码来源:ResPeekerToolWindowFactory.java

示例3: waitForAdb

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
public static void waitForAdb(AndroidDebugBridge adb, long timeoutMs) {
    long sleepTimeMs = TimeUnit.SECONDS.toMillis(1);
    while (!adb.hasInitialDeviceList() && timeoutMs > 0) {
        try {
            Thread.sleep(sleepTimeMs);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        timeoutMs -= sleepTimeMs;
    }
    if (timeoutMs <= 0 && !adb.hasInitialDeviceList()) {
        throw new RuntimeException("Timeout getting device list.", null);
    }
}
 
开发者ID:apptik,项目名称:tarator,代码行数:15,代码来源:Nuts.java

示例4: getDevice

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private static DeviceResult getDevice(Project project) {
    List<AndroidFacet> facets = getApplicationFacets(project);
    if (!facets.isEmpty()) {
        AndroidFacet facet = facets.get(0);
        String packageName = AdbUtil.computePackageName(facet);
        AndroidDebugBridge bridge = AndroidSdkUtils.getDebugBridge(project);
        if (bridge == null) {
            error("No platform configured");
            return null;
        }
        int count = 0;
        while (!bridge.isConnected() || !bridge.hasInitialDeviceList()) {
            try {
                Thread.sleep(100);
                count++;
            } catch (InterruptedException e) {
                // pass
            }

            // let's not wait > 10 sec.
            if (count > 100) {
                error("Timeout getting device list!");
                return null;
            }
        }

        IDevice[] devices = bridge.getDevices();
        if (devices.length == 1) {
            return new DeviceResult(devices, facet, packageName);
        } else if (devices.length > 1) {
            return askUserForDevice(facet, packageName);
        } else {
            return null;
        }

    }
    error("No devices found");
    return null;
}
 
开发者ID:layerlre,项目名称:ADBWIFI,代码行数:40,代码来源:AdbWifiConnect.java

示例5: waitDevicesList

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
/**
 * 等待查找device
 * 
 * @param bridge
 */
private void waitDevicesList(AndroidDebugBridge bridge) {
	int count = 0;
	while (bridge.hasInitialDeviceList() == false) {
		try {
			Thread.sleep(500);
			count++;
		} catch (InterruptedException e) {
		}
		if (count > 60) {
			System.err.print("等待获取设备超时");
			break;
		}
	}
}
 
开发者ID:androiddevelop,项目名称:AndroidScreenshot,代码行数:20,代码来源:ScreenShot.java

示例6: getDevice

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private DeviceResult getDevice(AnActionEvent anActionEvent) {
    List<AndroidFacet> facets = getApplicationFacets(anActionEvent.getProject());
    if (!facets.isEmpty()) {

        AndroidFacet facet = null;

        String androidFacetName = getAndroidFacetName(anActionEvent);

        if (androidFacetName != null) {
            for (AndroidFacet androidFacet : facets) {
                if (androidFacet.getModule().getName().equals(androidFacetName)) {
                    facet = androidFacet;
                }
            }
            if (facet == null) {
                return null;
            }

        } else {

            if (facets.size() > 1) {
                facet = ModuleChooserDialogHelper.showDialogForFacets(anActionEvent.getProject(), facets);
                if (facet == null) {
                    return null;
                }
            } else {
                facet = facets.get(0);
            }
        }
        String packageName =facet.getAndroidModuleInfo().getPackage();
        AndroidDebugBridge bridge = AndroidSdkUtils.getDebugBridge(anActionEvent.getProject());
        if (bridge == null) {
            error("No platform configured");
            return null;
        }

        if (bridge.isConnected() && bridge.hasInitialDeviceList()) {

            IDevice[] devices = bridge.getDevices();
            if (devices.length == 1) {
                return new DeviceResult(anActionEvent, devices[0], facet, packageName);
            } else if (devices.length > 1) {
                return askUserForDevice(anActionEvent, facet, packageName);
            } else {
                return new DeviceResult(anActionEvent, null, facet, null);
            }
        }
    }
    return new DeviceResult(anActionEvent, null, null, null);
}
 
开发者ID:zzz40500,项目名称:ADB-Duang,代码行数:51,代码来源:BaseAction.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

示例8: isAdbInitialized

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private boolean isAdbInitialized(AndroidDebugBridge adb) {
  return adb.isConnected() && adb.hasInitialDeviceList();
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:4,代码来源:AdbHelper.java

示例9: isAdbInitialized

import com.android.ddmlib.AndroidDebugBridge; //导入方法依赖的package包/类
private static boolean isAdbInitialized(AndroidDebugBridge adb) {
  return adb.isConnected() && adb.hasInitialDeviceList();
}
 
开发者ID:facebook,项目名称:buck,代码行数:4,代码来源:AdbHelper.java


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