Merge "Bug fix: null string will cause exception in checkStringInAdbCommandOutput"

This commit is contained in:
Syaoran Kuo
2021-06-25 08:41:45 +00:00
committed by Android (Google) Code Review

View File

@@ -43,10 +43,12 @@ public class AdbUtils {
public static boolean checkStringInAdbCommandOutput(String logTag, String command, public static boolean checkStringInAdbCommandOutput(String logTag, String command,
String prefix, String target, int timeoutInMillis) throws Exception { String prefix, String target, int timeoutInMillis) throws Exception {
long start = System.nanoTime(); long start = System.nanoTime();
//Sometimes the change do no reflect in adn output immediately, so need a wait and poll here //Sometimes the change do no reflect in adn output immediately, so need a wait and poll here
while (System.nanoTime() - start < (timeoutInMillis * 1000000)) { while (System.nanoTime() - start < (timeoutInMillis * 1000000)) {
String result = shell(command); String result = shell(command);
if (result.contains(prefix) && result.contains(target)) { if (result.contains(prefix == null ? "" : prefix)
&& result.contains(target == null ? "" : target)) {
return true; return true;
} else { } else {
Thread.sleep(100); Thread.sleep(100);