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


Java CollectingOutputReceiver.getOutput方法代码示例

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


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

示例1: execute

import com.android.ddmlib.CollectingOutputReceiver; //导入方法依赖的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

示例2: getWorkProfileId

import com.android.ddmlib.CollectingOutputReceiver; //导入方法依赖的package包/类
@Nullable
public static Integer getWorkProfileId(IDevice device)
    throws TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException,
        IOException {
  CollectingOutputReceiver receiver = new CollectingOutputReceiver();
  device.executeShellCommand("pm list users", receiver);
  String result = receiver.getOutput();
  Matcher matcher = USER_ID_REGEX.matcher(result);
  if (matcher.find()) {
    return Integer.parseInt(matcher.group(1));
  }
  return null;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:14,代码来源:UserIdHelper.java

示例3: checkReceiverOutput

import com.android.ddmlib.CollectingOutputReceiver; //导入方法依赖的package包/类
/**
 * This was made public for one specific call site in ExopackageInstaller.
 * If you're reading this, you probably shouldn't call it.  Pretend this method is private.
 */
public static String checkReceiverOutput(
    String command,
    CollectingOutputReceiver receiver) throws CommandFailedException {
  String fullOutput = receiver.getOutput();
  int colon = fullOutput.lastIndexOf(':');
  String realOutput = fullOutput.substring(0, colon);
  String exitCodeStr = fullOutput.substring(colon + 1);
  int exitCode = Integer.parseInt(exitCodeStr);
  if (exitCode != 0) {
    throw new CommandFailedException(command, exitCode, realOutput);
  }
  return realOutput;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:18,代码来源:AdbHelper.java

示例4: checkReceiverOutput

import com.android.ddmlib.CollectingOutputReceiver; //导入方法依赖的package包/类
private static String checkReceiverOutput(String command, CollectingOutputReceiver receiver)
    throws AdbHelper.CommandFailedException {
  String fullOutput = receiver.getOutput();
  int colon = fullOutput.lastIndexOf(':');
  String realOutput = fullOutput.substring(0, colon);
  String exitCodeStr = fullOutput.substring(colon + 1);
  int exitCode = Integer.parseInt(exitCodeStr);
  if (exitCode != 0) {
    throw new AdbHelper.CommandFailedException(command, exitCode, realOutput);
  }
  return realOutput;
}
 
开发者ID:facebook,项目名称:buck,代码行数:13,代码来源:RealAndroidDevice.java


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