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


Java TimeoutException类代码示例

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


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

示例1: run

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
@Override
public void run() {
    executorThread = Thread.currentThread();
    try {
        NullOutputReceiver outputReceiver = new NullOutputReceiver();
        /*
         * this execution will never throw a
         * ShellCommandUnresponsiveException
         */
        wrappedDevice.executeShellCommand(command, outputReceiver, 0, TimeUnit.MICROSECONDS);
    } catch (TimeoutException | AdbCommandRejectedException | IOException | ShellCommandUnresponsiveException e) {
        onExecutionException = new CommandFailedException("Shell command execution failed. See the enclosed exception for more information.",
                                                          e);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:16,代码来源:BackgroundShellCommandRunner.java

示例2: getScreenSizeInfo

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
/**
 * 获取设备分辨率
 */
private void getScreenSizeInfo(){
	RawImage rawScreen;
	try {
		rawScreen = idevice.getScreenshot();
		if(rawScreen != null){
			screenWidth = rawScreen.width;
			screenHeight = rawScreen.height;
		}else{
			
		}
	} catch (TimeoutException | AdbCommandRejectedException | IOException e) {
		// TODO Auto-generated catch block
		logger.error(serialNumber+":无法获取屏幕尺寸",e);
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:19,代码来源:DeviceEntity.java

示例3: getScreenshot

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
/**
 * Returns a JPEG compressed display screenshot.
 *
 * @return Image as base64 encoded {@link String}
 * @throws CommandFailedException
 *         In case of an error in the execution
 */
public String getScreenshot() throws CommandFailedException {
    shellCommandExecutor.execute(SCREENSHOT_COMMAND);

    FileInputStream fileReader = null;

    try {
        wrappedDevice.pullFile(SCREENSHOT_REMOTE_FILE_NAME, SCREENSHOT_LOCAL_FILE_NAME);

        File localScreenshotFile = new File(SCREENSHOT_LOCAL_FILE_NAME);
        fileReader = new FileInputStream(localScreenshotFile);

        final long sizeOfScreenshotFile = localScreenshotFile.length();
        byte[] screenshotData = new byte[(int) sizeOfScreenshotFile];
        fileReader.read(screenshotData);
        fileReader.close();

        String screenshotBase64String = Base64.getEncoder().encodeToString(screenshotData);

        return screenshotBase64String;
    } catch (IOException | AdbCommandRejectedException | TimeoutException | SyncException e) {
        LOGGER.error("Screenshot fetching failed.", e);
        throw new CommandFailedException("Screenshot fetching failed.", e);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:32,代码来源:ImageEntity.java

示例4: pushComponentFileToTemp

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
/**
 * Pushes a component file to the temp folder of the device.
 *
 * @param onDeviceComponent
 *        - the component that should be pushed.
 */
private void pushComponentFileToTemp(OnDeviceComponent onDeviceComponent) {
    String statusMessage = String.format(COMPONENT_INSTALLATION_MESSAGE, onDeviceComponent.getHumanReadableName());
    LOGGER.info(statusMessage);

    String componentPath = ON_DEVICE_COMPONENT_FILES_PATH.concat(onDeviceComponent.getFileName());
    String remotePath = TEMP_PATH.concat("/").concat(onDeviceComponent.getFileName());

    try {
        wrappedDevice.pushFile(componentPath, remotePath);
    } catch (SyncException | IOException | AdbCommandRejectedException | TimeoutException e) {
        String errorMessage = String.format(COMPONENT_INSTALLATION_FAILED_MESSAGE,
                                            onDeviceComponent.getHumanReadableName());
        LOGGER.fatal(errorMessage, e);
        throw new ComponentInstallationFailedException(errorMessage, e);
    }
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:23,代码来源:PreconditionsManager.java

示例5: execute

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
/**
 * Executes a command with a specified timeout on the device's shell and returns the result of the execution. If the
 * default timeout is grater than the requested one, default will be used.
 *
 * @param command
 *        - Shell command to be executed.
 * @param timeout
 *        - timeout to be used in the adb connection, when executing a command on the device.
 * @return Shell response from the command execution.
 * @throws CommandFailedException
 *         In case of an error in the execution
 */
public String execute(String command, int timeout) throws CommandFailedException {
    String response = "";

    int commandExecutionTimeout = Math.max(timeout, COMMAND_EXECUTION_TIMEOUT);

    try {
        CollectingOutputReceiver outputReceiver = new CollectingOutputReceiver();
        device.executeShellCommand(command, outputReceiver, commandExecutionTimeout);

        response = outputReceiver.getOutput();
    } catch (TimeoutException | AdbCommandRejectedException | ShellCommandUnresponsiveException | IOException e) {
        throw new CommandFailedException("Shell command execution failed.", e);
    }

    return response;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-agent,代码行数:29,代码来源:ShellCommandExecutor.java

示例6: getDeviceImage

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
private static void getDeviceImage(IDevice device, String filepath, boolean landscape)
        throws IOException {
    RawImage rawImage;

    try {
        rawImage = device.getScreenshot();
    } catch (TimeoutException e) {
        printAndExit("Unable to get frame buffer: timeout", true /* terminate */);
        return;
    } catch (Exception ioe) {
        printAndExit("Unable to get frame buffer: " + ioe.getMessage(), true /* terminate */);
        return;
    }

    // device/adb not available?
    if (rawImage == null)
        return;

    if (landscape) {
        rawImage = rawImage.getRotated();
    }

    // convert raw data to an Image
    BufferedImage image = new BufferedImage(rawImage.width, rawImage.height,
            BufferedImage.TYPE_INT_ARGB);

    int index = 0;
    int IndexInc = rawImage.bpp >> 3;
    for (int y = 0 ; y < rawImage.height ; y++) {
        for (int x = 0 ; x < rawImage.width ; x++) {
            int value = rawImage.getARGB(index);
            index += IndexInc;
            image.setRGB(x, y, value);
        }
    }

    if (!ImageIO.write(image, "png", new File(filepath))) {
        throw new IOException("Failed to find png writer");
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:41,代码来源:Screenshot.java

示例7: executeCommandOnDevice

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
public static void executeCommandOnDevice(@NotNull IDevice device,
                                          @NotNull String command,
                                          @NotNull AndroidOutputReceiver receiver,
                                          boolean infinite)
  throws IOException, TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
  int attempt = 0;
  while (attempt < 5) {
    if (infinite) {
      device.executeShellCommand(command, receiver, 0);
    }
    else {
      device.executeShellCommand(command, receiver, TIMEOUT);
    }
    if (infinite && !receiver.isCancelled()) {
      attempt++;
    }
    else if (receiver.isTryAgain()) {
      attempt++;
    }
    else {
      break;
    }
    receiver.invalidate();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:AndroidUtils.java

示例8: installApp

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
private InstallResult installApp(@NotNull IDevice device, @NotNull String remotePath)
  throws AdbCommandRejectedException, TimeoutException, IOException {

  MyReceiver receiver = new MyReceiver();
  try {
    executeDeviceCommandAndWriteToConsole(device, "pm install -r \"" + remotePath + "\"", receiver);
  }
  catch (ShellCommandUnresponsiveException e) {
    LOG.info(e);
    return new InstallResult(InstallFailureCode.DEVICE_NOT_RESPONDING, null, null);
  }

  return new InstallResult(getFailureCode(receiver),
                           receiver.failureMessage,
                           receiver.output.toString());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AndroidRunningState.java

示例9: launch

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
@Override
public LaunchResult launch(@NotNull AndroidRunningState state, @NotNull IDevice device)
  throws IOException, AdbCommandRejectedException, TimeoutException {
  state.getProcessHandler().notifyTextAvailable("Running tests\n", ProcessOutputTypes.STDOUT);
  RemoteAndroidTestRunner runner = new RemoteAndroidTestRunner(state.getTestPackageName(), myInstrumentationTestRunner, device);
  switch (TESTING_TYPE) {
    case TEST_ALL_IN_PACKAGE:
      runner.setTestPackageName(PACKAGE_NAME);
      break;
    case TEST_CLASS:
      runner.setClassName(CLASS_NAME);
      break;
    case TEST_METHOD:
      runner.setMethodName(CLASS_NAME, METHOD_NAME);
      break;
  }
  runner.setDebug(state.isDebugMode());
  try {
    runner.run(new AndroidTestListener(state));
  }
  catch (ShellCommandUnresponsiveException e) {
    LOG.info(e);
    state.getProcessHandler().notifyTextAvailable("Error: time out", ProcessOutputTypes.STDERR);
  }
  return LaunchResult.SUCCESS;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:AndroidTestRunConfiguration.java

示例10: getUserIdFromConfigurationState

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
@Nullable
public static Integer getUserIdFromConfigurationState(
    IDevice device, ConsolePrinter consolePrinter, BlazeAndroidBinaryRunConfigurationState state)
    throws ExecutionException {
  if (state.useWorkProfileIfPresent()) {
    try {
      Integer userId = getWorkProfileId(device);
      if (userId == null) {
        consolePrinter.stderr(
            "Could not locate work profile on selected device. Launching default user.\n");
      }
      return userId;
    } catch (TimeoutException
        | AdbCommandRejectedException
        | ShellCommandUnresponsiveException
        | IOException e) {
      throw new ExecutionException(e);
    }
  }
  return state.getUserId();
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:22,代码来源:UserIdHelper.java

示例11: drag

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
/**
 * 拖动
 * 
 * @param x
 * @param y
 */
public void drag(int x, int y) {
	try {
		device.executeShellCommand("sendevent /dev/input/event7 3 53 " + x
				* Config.WIDTH_SCALE / Config.SCREEN_SCALE,
				new ShellReceiver(System.out));
		device.executeShellCommand("sendevent /dev/input/event7 3 54 " + y
				* Config.HEIGHT_SCALE / Config.SCREEN_SCALE,
				new ShellReceiver(System.out));
		device.executeShellCommand("sendevent /dev/input/event7 0 2 0",
				new ShellReceiver(System.out));
		device.executeShellCommand("sendevent /dev/input/event7 0 0 0",
				new ShellReceiver(System.out));
	} catch (TimeoutException | AdbCommandRejectedException
			| ShellCommandUnresponsiveException | IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:androiddevelop,项目名称:AndroidScreenshot,代码行数:24,代码来源:ScreenShot.java

示例12: inputChar

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
/**
 * 输入字符
 * 
 * @param keycode
 */
public void inputChar(int keycode) {
	try {
		device.executeShellCommand("sendevent /dev/input/event7 1  "
				+ keycode + " 1", new ShellReceiver(System.out));
		device.executeShellCommand("sendevent /dev/input/event7 0 0 0",
				new ShellReceiver(System.out));

		device.executeShellCommand("sendevent /dev/input/event7 1  "
				+ keycode + " 0", new ShellReceiver(System.out));
		device.executeShellCommand("sendevent /dev/input/event7 0 0 0",
				new ShellReceiver(System.out));
	} catch (TimeoutException | AdbCommandRejectedException
			| ShellCommandUnresponsiveException | IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:androiddevelop,项目名称:AndroidScreenshot,代码行数:22,代码来源:ScreenShot.java

示例13: getHandleFileResult

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
String getHandleFileResult(final AndroidDevice aDevice, SubType subType,
		String localFile, String remoteFile) {

	try {
		switch (subType) {
		case PULL:
			aDevice.getDevice().pullFile(remoteFile, localFile);
			break;
		case PUSH:
			aDevice.getDevice().pushFile(localFile, remoteFile);
			break;
		default:
			break;
		}
	} catch (SyncException | IOException | AdbCommandRejectedException
			| TimeoutException e) {
		e.printStackTrace();

		return "Command failed:" + e.getLocalizedMessage();
	}

	return "Command success";
}
 
开发者ID:IPEldorado,项目名称:RemoteResources,代码行数:24,代码来源:Server.java

示例14: run

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
/**
 * Runs a {@link SyncRunnable} in a {@link ProgressMonitorDialog}.
 * @param runnable The {@link SyncRunnable} to run.
 * @param progressMessage the message to display in the progress dialog
 * @param parentShell the parent shell for the progress dialog.
 *
 * @throws InvocationTargetException
 * @throws InterruptedException
 * @throws SyncException if an error happens during the push of the package on the device.
 * @throws IOException
 * @throws TimeoutException
 */
public static void run(final SyncRunnable runnable, final String progressMessage )
        throws InterruptedException, SyncException, IOException,
        TimeoutException {
    
    new Thread(new Runnable() {
        
        @Override
        public void run() {
            final Exception[] result = new Exception[1];
            MainFrame frm = SmartToolsApp.getApp().getMainFrm();
            MyProgessBar bar = frm.getProgressBar();
            
            try {
                System.out.println("SyncProgressHelper: run");
                runnable.run(new SyncProgressMonitor(bar, progressMessage));
            } catch (Exception e) {
                result[0] = e;
            } finally {
                runnable.close();
            }
        }
    }).start();
    
}
 
开发者ID:HoneyFish,项目名称:SmartTools,代码行数:37,代码来源:SyncProgressHelper.java

示例15: performAction

import com.android.ddmlib.TimeoutException; //导入依赖的package包/类
@Override
protected void performAction(Node[] activatedNodes) {
    for (Node activatedNode : activatedNodes) {
        DevicesNode.MobileDeviceHolder holder = activatedNode.getLookup().lookup(DevicesNode.MobileDeviceHolder.class);
        if (holder != null) {
            try {
                holder.getMasterDevice().reboot(null);
            } catch (TimeoutException | AdbCommandRejectedException | IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:14,代码来源:RebootDeviceAdbAction.java


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