summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-10-11 20:27:51 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2022-10-11 20:27:51 +0000
commite3d9e48a6681bca72a92dd6b6e397da5765c2fc6 (patch)
tree6f43d4ba302e336dffd3d590dfb24024af30228e
parent1142bf016b41e5555c41410e80c1d516dcde9447 (diff)
parentdf83d2d799df367f4e4c89a88581fb4d2097f405 (diff)
downloadcts-sparse-9163417-L27600000957240203.tar.gz
Merge "Snap for 9163022 from 23c56a47d01f6929575c62373cfbdde6881b5836 to android12-tests-release" into android12-tests-releasesparse-9163417-L35300000957234347sparse-9163417-L29000000957205363sparse-9163417-L27600000957240203
-rw-r--r--hostsidetests/appsecurity/src/android/appsecurity/cts/ResumeOnRebootHostTest.java40
-rw-r--r--tools/cts-tradefed/res/config/cts-exclude.xml1
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" />