[xTS] Ensure VM attestation is supported for vendor API >= 202504
Removed the feature flag check in test as the VM attestation
feature has been fully enabled since Android 15 release.
Bug: 365692904
Test: atest MicrodroidTests
Change-Id: I772d47b38b85f6537453a7d84fdcf1c8c39bdb41
diff --git a/tests/helper/src/java/com/android/microdroid/test/device/MicrodroidDeviceTestBase.java b/tests/helper/src/java/com/android/microdroid/test/device/MicrodroidDeviceTestBase.java
index 2986bdc..e6f15ff 100644
--- a/tests/helper/src/java/com/android/microdroid/test/device/MicrodroidDeviceTestBase.java
+++ b/tests/helper/src/java/com/android/microdroid/test/device/MicrodroidDeviceTestBase.java
@@ -21,6 +21,7 @@
import static android.content.pm.PackageManager.FEATURE_WATCH;
import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.TruthJUnit.assume;
import static org.junit.Assume.assumeFalse;
@@ -257,6 +258,14 @@
return SystemProperties.getInt("ro.board.api_level", 0);
}
+ /**
+ * @return The first vendor API level when the vendor images for an SoC that is qualified for
+ * vendor freeze are first released with this property, or 0 if the property is not set.
+ */
+ protected static int getFirstVendorApiLevel() {
+ return SystemProperties.getInt("ro.board.first_api_level", 0);
+ }
+
protected void assumeSupportedDevice() {
assume().withMessage("Skip on 5.4 kernel. b/218303240")
.that(KERNEL_VERSION)
@@ -277,6 +286,24 @@
.isFalse();
}
+ protected void ensureVmAttestationSupported() throws Exception {
+ // The first vendor API level is checked because VM attestation requires the VM DICE chain
+ // to be ROM-rooted.
+ int firstVendorApiLevel = getFirstVendorApiLevel();
+ boolean isRemoteAttestationSupported =
+ getVirtualMachineManager().isRemoteAttestationSupported();
+ if (firstVendorApiLevel >= 202504) {
+ assertWithMessage(
+ "First vendor API '"
+ + firstVendorApiLevel
+ + "' (>=202504) must support VM remote attestation")
+ .that(isRemoteAttestationSupported)
+ .isTrue();
+ } else {
+ assumeTrue("Skip on VM remote attestation not supported", isRemoteAttestationSupported);
+ }
+ }
+
public abstract static class VmEventListener implements VirtualMachineCallback {
private ExecutorService mExecutorService = Executors.newSingleThreadExecutor();
private OptionalLong mVcpuStartedNanoTime = OptionalLong.empty();
diff --git a/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java b/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
index e69b8f6..dff408c 100644
--- a/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
+++ b/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
@@ -301,10 +301,7 @@
public void vmAttestationWhenRemoteAttestationIsSupported() throws Exception {
// pVM remote attestation is only supported on protected VMs.
assumeProtectedVM();
- assumeFeatureEnabled(VirtualMachineManager.FEATURE_REMOTE_ATTESTATION);
- assume().withMessage("Test needs Remote Attestation support")
- .that(getVirtualMachineManager().isRemoteAttestationSupported())
- .isTrue();
+ ensureVmAttestationSupported();
VirtualMachineConfig config =
newVmConfigBuilderWithPayloadBinary(VM_ATTESTATION_PAYLOAD_PATH)
.setProtectedVm(mProtectedVm)