com.android.ddmlib.CollectingOutputReceiver Java Examples
The following examples show how to use
com.android.ddmlib.CollectingOutputReceiver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserIdHelper.java From intellij with Apache License 2.0 | 5 votes |
@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; }
Example #2
Source File: RealAndroidDevice.java From buck with Apache License 2.0 | 5 votes |
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; }
Example #3
Source File: RealAndroidDevice.java From buck with Apache License 2.0 | 5 votes |
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); }
Example #4
Source File: RealAndroidDevice.java From buck with Apache License 2.0 | 5 votes |
/** 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; }