• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CollectingOutputReceiver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: record

import com.android.ddmlib.CollectingOutputReceiver; //导入依赖的package包/类
/**
 * 启动录制
 *
 * @throws Exception
 */
private static void record() throws Exception {
    if ((isRecording == false) && (lastItem[0] != null)
        && (lastItem[0].getData("device") != null)) {
        device = (IDevice) lastItem[0].getData("device");
        deviceIndex = (Integer) lastItem[0].getData("index");
    }

    if (device != null) {
        enableRecord(false);
        isSetCheckPoint = false;
        client = new UiAutomatorClient(device.getSerialNumber());
        if (client.connect()) {
            enableRecordButton(true, true, true, true, true, true);
            mWidth = client.getDisplayWidth();
            mHeight = client.getDisplayHeight();
            //向手机注入Minicap截图工具
            String sdk = device.getProperty("ro.build.version.sdk");
            String abi = device.getProperty("ro.product.cpu.abi");
            device.pushFile(System.getProperty("user.dir")
                            + ("/plugins/resources/minicap/bin/" + abi + "/minicap"),
                "/data/local/tmp/minicap");
            File minicapFile = new File(System.getProperty("user.dir")
                                        + ("/plugins/resources/minicap/shared/android-" + sdk
                                           + "/" + abi + "/minicap.so"));
            if (minicapFile.exists() == false)
                sdk = "M";
            device
                .pushFile(
                    System.getProperty("user.dir")
                            + ("/plugins/resources/minicap/shared/android-" + sdk + "/" + abi + "/minicap.so"),
                    "/data/local/tmp/minicap.so");

            CollectingOutputReceiver receiver = new CollectingOutputReceiver();
            device.executeShellCommand("chmod 777 /data/local/tmp/minicap", receiver);
            device.executeShellCommand("chmod 777 /data/local/tmp/minicap.so", receiver);
            device.executeShellCommand("dumpsys window displays", receiver);

            minicap = new LaunchMinicap(device.getSerialNumber(), mWidth, mHeight, mWidth,
                mHeight, 0);
            Thread thread = new Thread(minicap);
            thread.start();
            thread.join(10000);
            AdbUtil.send("adb -s " + device.getSerialNumber()
                         + " forward tcp:1313 localabstract:minicap", 3000);
            deviceClient = new DeviceSocketClient(display, gc);
            deviceClient.connect("127.0.0.1", 1313);
        } else {
            enableRecordButton(false, false, false, false, false, false);
            enableRecord(true);
        }
    } else {
        MessageBox box = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
        box.setMessage("请先选择一个设备!");
        box.open();
    }
}
 
开发者ID:hoozheng,项目名称:AndroidRobot,代码行数:62,代码来源:AndroidRobot.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RemoveCallback类代码示例发布时间:2022-05-22
下一篇:
Java ReactModule类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap