@Override
public void init() throws DeviceException {
try {
AndroidDebugBridge.initIfNeeded(false /*clientSupport*/);
AndroidDebugBridge bridge = AndroidDebugBridge.createBridge(
sdkParser.getAdb().getAbsolutePath(), false /*forceNewBridge*/);
long timeOut = 30000; // 30 sec
int sleepTime = 1000;
while (!bridge.hasInitialDeviceList() && timeOut > 0) {
Thread.sleep(sleepTime);
timeOut -= sleepTime;
}
if (timeOut <= 0 && !bridge.hasInitialDeviceList()) {
throw new RuntimeException("Timeout getting device list.", null);
}
IDevice[] devices = bridge.getDevices();
if (devices.length == 0) {
throw new RuntimeException("No connected devices!", null);
}