This repository has been archived by the owner on Nov 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from sbtqa/move-plotva
Move plotva
- Loading branch information
Showing
5 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/ru/sbtqa/tag/pagefactory/support/AdbConsole.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package ru.sbtqa.tag.pagefactory.support; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import ru.sbtqa.tag.pagefactory.drivers.TagMobileDriver; | ||
|
||
public class AdbConsole { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(AdbConsole.class); | ||
|
||
private AdbConsole() { | ||
throw new IllegalAccessError("Utility class"); | ||
} | ||
|
||
public static boolean execute(String command) { | ||
return execute(TagMobileDriver.getDeviceUDID(), command); | ||
} | ||
|
||
public static boolean execute(String deviceUDID, String command) { | ||
ProcessBuilder processBuilder = new ProcessBuilder(new String[]{"adb", "-s", deviceUDID, "shell", command}); | ||
LOG.info("Command '{}' is processing...", command); | ||
try { | ||
Process process = processBuilder.start(); | ||
|
||
BufferedReader reader | ||
= new BufferedReader(new InputStreamReader(process.getInputStream())); | ||
StringBuilder builder = new StringBuilder(); | ||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
builder.append(line); | ||
builder.append(System.getProperty("line.separator")); | ||
} | ||
LOG.debug(builder.toString()); | ||
|
||
return process.waitFor() == 0; | ||
} catch (IOException | InterruptedException ex) { | ||
LOG.error("Failed to process command '{}'", command, ex); | ||
} | ||
|
||
return false; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters