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


Java CollectingOutputReceiver类代码示例

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


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

import com.android.ddmlib.CollectingOutputReceiver; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String data, AckRequest ackSender)
		throws Exception {
	if (data != null) {
		CommandBean commandBean = JsonUtil.jsonTobean(data,
				CommandBean.class);
		if (commandBean != null && commandBean.getSerList() != null
				&& commandBean.getCommand() != null) {
			for (String sernum : commandBean.getSerList()) {
				executorService.execute(new Runnable() {

					@Override
					public void run() {
						DeviceEntity deviceEntity = DeviceContainerHandler
								.getDevice(sernum);
						if (deviceEntity != null) {
							IDevice idevice = deviceEntity.getIdevice();
							if (idevice.isOnline()) {
								CollectingOutputReceiver receiver = new CollectingOutputReceiver();
								try {
									idevice.executeShellCommand(
											commandBean.getCommand(),
											receiver);
								} catch (TimeoutException
										| AdbCommandRejectedException
										| ShellCommandUnresponsiveException
										| IOException e) {
									logger.error("执行命令发送异常", e);
								}
								receiver.flush();
								logger.info(receiver.getOutput());
							}
						}
					}
				});
			}
		}
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:40,代码来源:CommandListener.java

示例3: performAction

import com.android.ddmlib.CollectingOutputReceiver; //导入依赖的package包/类
public void performAction() {
  final ScreenRecorderOptionsDialog dialog = new ScreenRecorderOptionsDialog(myProject);
  if (!dialog.showAndGet()) {
    return;
  }

  final ScreenRecorderOptions options = dialog.getOptions();

  final CountDownLatch latch = new CountDownLatch(1);
  final CollectingOutputReceiver receiver = new CollectingOutputReceiver(latch);

  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      try {
        myDevice.startScreenRecorder(REMOTE_PATH, options, receiver);
      }
      catch (Exception e) {
        showError(myProject, "Unexpected error while launching screen recorder", e);
        latch.countDown();
      }
    }
  });

  Task.Modal screenRecorderShellTask = new ScreenRecorderTask(myProject, myDevice, latch, receiver);
  screenRecorderShellTask.setCancelText("Stop Recording");
  screenRecorderShellTask.queue();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ScreenRecorderAction.java

示例4: ScreenRecorderTask

import com.android.ddmlib.CollectingOutputReceiver; //导入依赖的package包/类
public ScreenRecorderTask(@NotNull Project project,
                          @NotNull IDevice device,
                          @NotNull CountDownLatch completionLatch,
                          @NotNull CollectingOutputReceiver receiver) {
  super(project, TITLE, true);

  myDevice = device;
  myCompletionLatch = completionLatch;
  myReceiver = receiver;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ScreenRecorderAction.java

示例5: 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

示例6: executeCommandWithErrorChecking

import com.android.ddmlib.CollectingOutputReceiver; //导入依赖的package包/类
/**
 * Runs a command on a device and throws an exception if it fails.
 *
 * <p>This will not work if your command contains "exit" or "trap" statements.
 *
 * @param device Device to run the command on.
 * @param command Shell command to execute.  Must not use "exit" or "trap".
 * @return The full text output of the command.
 * @throws CommandFailedException if the command fails.
 */
public static String executeCommandWithErrorChecking(IDevice device, String command)
    throws
    TimeoutException,
    AdbCommandRejectedException,
    ShellCommandUnresponsiveException,
    IOException {
  CollectingOutputReceiver receiver = new CollectingOutputReceiver();
  device.executeShellCommand(command + " ; echo -n :$?", receiver);
  String realOutput = checkReceiverOutput(command, receiver);
  return realOutput;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:22,代码来源:AdbHelper.java

示例7: 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

示例8: deviceGetExternalStorage

import com.android.ddmlib.CollectingOutputReceiver; //导入依赖的package包/类
/**
 * Retrieves external storage location (SD card) from device.
 */
private String deviceGetExternalStorage(IDevice device) throws TimeoutException,
    AdbCommandRejectedException, ShellCommandUnresponsiveException, IOException {
  CollectingOutputReceiver receiver = new CollectingOutputReceiver();
  device.executeShellCommand(
      "echo $EXTERNAL_STORAGE",
      receiver,
      AdbHelper.GETPROP_TIMEOUT,
      TimeUnit.MILLISECONDS);
  String value = receiver.getOutput().trim();
  if (value.isEmpty()) {
    return null;
  }
  return value;
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:18,代码来源:AdbHelper.java

示例9: 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

示例10: executeCommandWithErrorChecking

import com.android.ddmlib.CollectingOutputReceiver; //导入依赖的package包/类
private String executeCommandWithErrorChecking(String command)
    throws TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException,
        IOException {
  CollectingOutputReceiver receiver = new CollectingOutputReceiver();
  device.executeShellCommand(command + ECHO_COMMAND_SUFFIX, receiver);
  return checkReceiverOutput(command, receiver);
}
 
开发者ID:facebook,项目名称:buck,代码行数:8,代码来源:RealAndroidDevice.java

示例11: deviceGetExternalStorage

import com.android.ddmlib.CollectingOutputReceiver; //导入依赖的package包/类
/** Retrieves external storage location (SD card) from device. */
@Nullable
private String deviceGetExternalStorage()
    throws TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException,
        IOException {
  CollectingOutputReceiver receiver = new CollectingOutputReceiver();
  device.executeShellCommand(
      "echo $EXTERNAL_STORAGE", receiver, GETPROP_TIMEOUT, TimeUnit.MILLISECONDS);
  String value = receiver.getOutput().trim();
  if (value.isEmpty()) {
    return null;
  }
  return value;
}
 
开发者ID:facebook,项目名称:buck,代码行数:15,代码来源:RealAndroidDevice.java

示例12: onData

import com.android.ddmlib.CollectingOutputReceiver; //导入依赖的package包/类
@Override
	public void onData(SocketIOClient client, String str, AckRequest ackRequest) throws Exception {
		logger.info(str);
		OpenActivityBean bean = JsonUtil.jsonTobean(str, OpenActivityBean.class);
//		OpenActivityBean noAPPDevicebean = new OpenActivityBean();
		if (bean != null) {
			String packageName = bean.getPackageName();
			String activityName = bean.getActivityName();
			List<String> serialNumberList = bean.getSerialNumList();
//			noAPPDevicebean.setPackageName(packageName);
//			noAPPDevicebean.setActivityName(activityName);
			//List<String> noAppDeviceList = new ArrayList<>();
			if (packageName != null && activityName != null && serialNumberList != null) {
				for (String serialNumber : serialNumberList) {
					DeviceEntity deviceEntity = DeviceContainerHandler.getDevice(serialNumber);
					if (deviceEntity != null) {
						IDevice idevice = deviceEntity.getIdevice();
						if (idevice != null) {
							executorService.execute(new Runnable() {
								@Override
								public void run() {
									CollectingOutputReceiver receiver = new CollectingOutputReceiver();
									try {
										idevice.executeShellCommand(
												String.format(COMMAND, packageName.trim(), activityName.trim()),
												receiver);
										logger.info(String.format(COMMAND, packageName.trim(), activityName.trim()));
										String appInfo = receiver.getOutput().trim();
										if (appInfo.endsWith("does not exist.")) {
											SystemWSSender.warn(client,"该应用在设备["+serialNumber+"]上尚未安装,请先安装");
										}
									} catch (TimeoutException | AdbCommandRejectedException
											| ShellCommandUnresponsiveException | IOException e) {
										logger.error("打开应用activity出错", e);
									}
								}
							});
						}
					}
				}
//				noAPPDevicebean.setSerialNumList(noAppDeviceList);
//				String noAppDeviceStr=JsonUtil.beanToJson(noAPPDevicebean);
//				System.out.println(noAppDeviceStr);
			}
		}
	}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:47,代码来源:OpenPackageActivityListener.java

示例13: startMinicap

import com.android.ddmlib.CollectingOutputReceiver; //导入依赖的package包/类
/**
 * 打开minicap
 */
public void startMinicap(final int virtualWidth, final int virtualHeight) {
	MinicapEntity minicapEntity = deviceEntity.getMinicapEntity();
	if (minicapEntity != null) {
		// 新建进程,开始监听屏幕数据
		Thread thread = new Thread(new Runnable() {

			@Override
			public void run() {
				if (idevice.isOnline()) {
					// 启动程序
					CollectingOutputReceiver receiver = new CollectingOutputReceiver();
					logger.info(deviceEntity.getSerialNumber()
							+ ":minicap启动");
					try {
						String command = String.format(
								MINICAP_START_COMMAND, bin,
								deviceEntity.getScreenWidth(),
								deviceEntity.getScreenHeight(),
								virtualWidth, virtualHeight);

						// logger.info(command);
						minicapEntity.setStatus(Status.RUNNING);// 设置minicap状态为运行中
						idevice.executeShellCommand(command, receiver, 0);
					} catch (TimeoutException | AdbCommandRejectedException
							| ShellCommandUnresponsiveException
							| IOException e) {
						logger.error(deviceEntity.getSerialNumber()
								+ ":监听屏幕出错", e);
					}
					logger.info(deviceEntity.getSerialNumber()
							+ ":minicap下线");
					receiver.flush();
					logger.info(receiver.getOutput());
					receiver.cancel();
				}
			}
		}, "MinicapAndroidThread-" + deviceEntity.getSerialNumber());
		deviceEntity.getMinicapEntity().setMinicapCMDThread(thread);
		thread.start();
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:45,代码来源:MinicapManager.java

示例14: getExternalStoragePath

import com.android.ddmlib.CollectingOutputReceiver; //导入依赖的package包/类
public String getExternalStoragePath() throws Exception {
    CollectingOutputReceiver pathNameOutputReceiver = new CollectingOutputReceiver();
    iDevice.executeShellCommand("echo $EXTERNAL_STORAGE", pathNameOutputReceiver);
    return pathNameOutputReceiver.getOutput().trim();
}
 
开发者ID:apptik,项目名称:tarator,代码行数:6,代码来源:TaratorDevice.java

示例15: ShellTask

import com.android.ddmlib.CollectingOutputReceiver; //导入依赖的package包/类
public ShellTask(@NotNull Project project, @NotNull CountDownLatch completionLatch, @NotNull CollectingOutputReceiver receiver) {
  super(project, TITLE, true);

  myCompletionLatch = completionLatch;
  myReceiver = receiver;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:DumpSysAction.java


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