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


Java AdbCommandRejectedException类代码示例

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


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

示例1: run

import com.android.ddmlib.AdbCommandRejectedException; //导入依赖的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.AdbCommandRejectedException; //导入依赖的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.AdbCommandRejectedException; //导入依赖的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.AdbCommandRejectedException; //导入依赖的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.AdbCommandRejectedException; //导入依赖的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: executeCommandOnDevice

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

示例7: launch

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

示例8: getUserIdFromConfigurationState

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

示例9: drag

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

示例10: inputChar

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

示例11: getHandleFileResult

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

示例12: createForward

import com.android.ddmlib.AdbCommandRejectedException; //导入依赖的package包/类
@Override
public AutoCloseable createForward() throws Exception {
  device.createForward(agentPort, agentPort);
  return () -> {
    try {
      device.removeForward(agentPort, agentPort);
    } catch (AdbCommandRejectedException e) {
      LOG.warn(e, "Failed to remove adb forward on port %d for device %s", agentPort, device);
      eventBus.post(
          ConsoleEvent.warning(
              "Failed to remove adb forward %d. This is not necessarily a problem\n"
                  + "because it will be recreated during the next exopackage installation.\n"
                  + "See the log for the full exception.",
              agentPort));
    }
  };
}
 
开发者ID:facebook,项目名称:buck,代码行数:18,代码来源:RealAndroidDevice.java

示例13: performAction

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

示例14: onData

import com.android.ddmlib.AdbCommandRejectedException; //导入依赖的package包/类
@Override
public void onData(SocketIOClient client, String data, AckRequest ackSender)
		throws Exception {
	PushBean bean = JsonUtil.jsonTobean(data, PushBean.class);
	if(bean != null){
		List<String> serialNumberList = bean.getSerialNumberList();
		String localPath = bean.getLocalPath();
		String remotePath = bean.getRemotePath();
		if(serialNumberList != null && localPath != null && remotePath != null && FileUtil.isFileExist(localPath)){
			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() {
								try {
									SystemWSSender.msg(client, "正在发送文件到["+deviceEntity.getSerialNumber()+"]:"+remotePath);
									logger.info(remotePath);
									idevice.pushFile(localPath, remotePath);
									SystemWSSender.msg(client, "文件成功发送到 "+deviceEntity.getSerialNumber());
								} catch (SyncException | IOException
										| AdbCommandRejectedException
										| TimeoutException e) {
									logger.info("文件发送出错",e);
									SystemWSSender.warn("["+deviceEntity.getSerialNumber()+"] 文件发送出错"+e.getMessage());
								}
							}
						});
					}
				}
			}
		}
	}
}
 
开发者ID:GroupControlDroid,项目名称:GroupControlDroidClient,代码行数:38,代码来源:PushFileListener.java

示例15: onData

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


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