Merge "Bug fix: null string will cause exception in checkStringInAdbCommandOutput"
diff --git a/tests/componenttests/src/com/android/settings/testutils/AdbUtils.java b/tests/componenttests/src/com/android/settings/testutils/AdbUtils.java
index 81f9854..b6e3c52 100644
--- a/tests/componenttests/src/com/android/settings/testutils/AdbUtils.java
+++ b/tests/componenttests/src/com/android/settings/testutils/AdbUtils.java
@@ -43,10 +43,12 @@
public static boolean checkStringInAdbCommandOutput(String logTag, String command,
String prefix, String target, int timeoutInMillis) throws Exception {
long start = System.nanoTime();
+
//Sometimes the change do no reflect in adn output immediately, so need a wait and poll here
while (System.nanoTime() - start < (timeoutInMillis * 1000000)) {
String result = shell(command);
- if (result.contains(prefix) && result.contains(target)) {
+ if (result.contains(prefix == null ? "" : prefix)
+ && result.contains(target == null ? "" : target)) {
return true;
} else {
Thread.sleep(100);