diff options
-rw-r--r-- | hostsidetests/appsecurity/src/android/appsecurity/cts/ResumeOnRebootHostTest.java | 40 | ||||
-rw-r--r-- | tools/cts-tradefed/res/config/cts-exclude.xml | 1 |
2 files changed, 35 insertions, 6 deletions
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/ResumeOnRebootHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/ResumeOnRebootHostTest.java index c5fad14ab22..0ba83e2d446 100644 --- a/hostsidetests/appsecurity/src/android/appsecurity/cts/ResumeOnRebootHostTest.java +++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/ResumeOnRebootHostTest.java @@ -40,6 +40,8 @@ import org.junit.runner.RunWith; import java.util.ArrayList; import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Set of tests that verify behavior of Resume on Reboot, if supported. @@ -68,6 +70,7 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { private static final int USER_SWITCH_TIMEOUT_SECONDS = 10; private static final long USER_SWITCH_WAIT = TimeUnit.SECONDS.toMillis(10); + private static final int UNLOCK_BROADCAST_WAIT_SECONDS = 10; private boolean mSupportsMultiUser; @@ -515,13 +518,33 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { runDeviceTestsAsUser("testUnlockScreen", userId); } + private void verifyLskfCaptured() throws Exception { + HostSideTestUtils.waitUntil( + "Lskf isn't captured after " + UNLOCK_BROADCAST_WAIT_SECONDS + " seconds", + UNLOCK_BROADCAST_WAIT_SECONDS, this::isLskfCapturedBasedOnDumpsys); + } + + private boolean isLskfCapturedBasedOnDumpsys() throws DeviceNotAvailableException { + Pattern pattern = Pattern.compile("\\w*mRebootEscrowReady=((?i)true|false(?-i))"); + String lockSettingsDumpsys = getDevice().executeShellCommand("dumpsys lock_settings"); + Matcher matcher = pattern.matcher(lockSettingsDumpsys); + if (!matcher.find()) { + CLog.d("lock_settings dumpsys did not contain mRebootEscrowReady entry. " + + "Assuming reboot escrow is not ready"); + return false; + } + return "true".equalsIgnoreCase(matcher.group(1)); + } + private void deviceRebootAndApply() throws Exception { deviceRebootAndApply(PKG); } private void deviceRebootAndApply(String clientName) throws Exception { - String res = getDevice().executeShellCommand("cmd recovery reboot-and-apply " + clientName - + " cts-test"); + verifyLskfCaptured(); + + String res = executeShellCommandWithLogging( + "cmd recovery reboot-and-apply " + clientName + " cts-test"); if (res != null && res.contains("Reboot and apply status: failure")) { fail("could not call reboot-and-apply"); } @@ -557,10 +580,7 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { } private void stopUserAsync(int userId) throws Exception { - String stopUserCommand = "am stop-user -f " + userId; - CLog.d("starting command \"" + stopUserCommand); - CLog.d("Output for command " + stopUserCommand + ": " - + getDevice().executeShellCommand(stopUserCommand)); + executeShellCommandWithLogging("am stop-user -f " + userId); } private void removeUser(int userId) throws Exception { @@ -617,4 +637,12 @@ public class ResumeOnRebootHostTest extends BaseHostJUnit4Test { super(getDevice(), getBuild(), getAbi()); } } + + private String executeShellCommandWithLogging(String command) + throws DeviceNotAvailableException { + CLog.d("Starting command: " + command); + String result = getDevice().executeShellCommand(command); + CLog.d("Output for command \"" + command + "\": " + result); + return result; + } } diff --git a/tools/cts-tradefed/res/config/cts-exclude.xml b/tools/cts-tradefed/res/config/cts-exclude.xml index 3d66c33acc5..c62ac11de13 100644 --- a/tools/cts-tradefed/res/config/cts-exclude.xml +++ b/tools/cts-tradefed/res/config/cts-exclude.xml @@ -33,6 +33,7 @@ instead). --> <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:exclude-annotation:com.android.compatibility.common.util.CtsDownstreamingTest" /> <option name="compatibility:test-arg" value="com.android.compatibility.common.tradefed.testtype.JarHostTest:exclude-annotation:com.android.compatibility.common.util.CtsDownstreamingTest" /> + <option name="compatibility:test-arg" value="com.android.tradefed.testtype.HostTest:exclude-annotation:com.android.compatibility.common.util.CtsDownstreamingTest" /> <!-- Exclude @SecurityTest tests from CTS. These are tested in STS. b/180417031--> <option name="compatibility:test-arg" value="com.android.tradefed.testtype.AndroidJUnitTest:exclude-annotation:android.platform.test.annotations.AsbSecurityTest" /> |