DO NOT MERGE SdkExtensionsTest: allow newer (unknown) versions Sometimes a device under test runs a newer version of SdkExtensions (where SDK extension version X has been finalized), and the SdkExtensionsTest come from an older build (where SDK extension version X-1 is the latest finalized version). This currently breaks the tests, because the test expects SDK extension version X-1, but finds X. SDK extensions are backwards compatible. Update the tests to allow the latest known SDK extension version at the time of compilation (of the test), or any newer version. This CL is a (modified) cherry-pick of aosp/3189531. Test: atest CtsSdkExtensionsTestCases Bug: 353314859 Bug: 362188245 Flag: EXEMPT test modification only, no change to OTA code Merged-In: I79cfb8ff83af15bbadea147a46b182d93615662f Change-Id: I1fa6f339fd05b60eead04f0d3f1afee5880754e2
diff --git a/tests/cts/Extensions/src/android/os/ext/cts/SdkExtensionsTest.java b/tests/cts/Extensions/src/android/os/ext/cts/SdkExtensionsTest.java index 1b54522..63be835 100644 --- a/tests/cts/Extensions/src/android/os/ext/cts/SdkExtensionsTest.java +++ b/tests/cts/Extensions/src/android/os/ext/cts/SdkExtensionsTest.java
@@ -26,11 +26,18 @@ public class SdkExtensionsTest extends TestCase { - // Android S launched with 1. Since then, version 2 was added. - private static final Set<Integer> ALLOWED_VERSIONS = Set.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14); + /** The version R shipped with (0) */ + public static final int R_BASE_VERSION = 0; + + /** The version S shipped with (1) */ + public static final int S_BASE_VERSION = 1; private static void assertCorrectVersion(int version) throws Exception { - assertTrue(ALLOWED_VERSIONS.contains(version)); + int minVersion = R_BASE_VERSION; + if (SdkLevel.isAtLeastS()) { + minVersion = S_BASE_VERSION; + } + assertTrue(version >= minVersion); } private static void assertCorrectVersion(boolean expected, String propValue) throws Exception { if (expected) {