Make 2021 CTS SIM required for T.
This SIM spec has been available since S, but we allowed a migration
period for one release cycle to ensure all testers now have updated
SIMs. The 2021 SIM is backwards compatible with the "legacy" CTS SIMs,
and includes its certificate as well as a newer one.
We update the CarrierApi suite's failure message to very clearly
indicate when a legacy SIM is still detected on T+ tests and point to
the 2021 spec.
Bug: 179534693
Test: make, use keytool to inspect test APK signature
Test: atest CtsCarrierApiTestCases (with new + old SIMs)
Change-Id: Ic61bc8178e5fb736b0652c22964d856ef46371ac
diff --git a/common/device-side/util-axt/src/com/android/compatibility/common/util/UiccUtil.java b/common/device-side/util-axt/src/com/android/compatibility/common/util/UiccUtil.java
index 7eb0b53..4adab28 100644
--- a/common/device-side/util-axt/src/com/android/compatibility/common/util/UiccUtil.java
+++ b/common/device-side/util-axt/src/com/android/compatibility/common/util/UiccUtil.java
@@ -82,18 +82,23 @@
public static final String SW1_OK_PROACTIVE_COMMAND = "91";
}
- /** The hashes of all supported CTS UICC test keys and their corresponding specification. */
+ /**
+ * The hashes of all supported CTS UICC test keys and their corresponding specification.
+ *
+ * <p>For up-to-date information about the CTS SIM specification, please see
+ * https://source.android.com/devices/tech/config/uicc#validation.
+ */
@StringDef({UiccCertificate.CTS_UICC_LEGACY, UiccCertificate.CTS_UICC_2021})
public @interface UiccCertificate {
/**
* Indicates compliance with the "legacy" CTS UICC specification (prior to 2021).
*
- * <p>Deprecated as of 2021, support to be removed in 2022.
- *
* <p>Corresponding certificate: {@code aosp-testkey}.
+ *
+ * @deprecated as of 2021, and no longer supported as of 2022.
*/
- String CTS_UICC_LEGACY = "61ED377E85D386A8DFEE6B864BD85B0BFAA5AF81";
+ @Deprecated String CTS_UICC_LEGACY = "61ED377E85D386A8DFEE6B864BD85B0BFAA5AF81";
/**
* Indicates compliance with the 2021 CTS UICC specification.
diff --git a/tests/tests/carrierapi/Android.bp b/tests/tests/carrierapi/Android.bp
index fec65d3..2c2e66f 100644
--- a/tests/tests/carrierapi/Android.bp
+++ b/tests/tests/carrierapi/Android.bp
@@ -41,9 +41,8 @@
"CtsCarrierApiTargetPrep",
"cts-tradefed",
],
- // This APK must be signed to match the test SIM's cert whitelist. While
- // "testkey" is the default, there are different per-device testkeys, so
- // hard-code the AOSP default key to ensure it is used regardless of build
+ // This APK must be signed to match the test SIM's carrier privilege rules.
+ // Hard-code the CTS SIM's test key to ensure it is used regardless of build
// environment.
- certificate: ":aosp-testkey",
+ certificate: ":cts-uicc-2021-testkey",
}
diff --git a/tests/tests/carrierapi/src/android/carrierapi/cts/BaseCarrierApiTest.java b/tests/tests/carrierapi/src/android/carrierapi/cts/BaseCarrierApiTest.java
index b0b6504..ee1d702 100644
--- a/tests/tests/carrierapi/src/android/carrierapi/cts/BaseCarrierApiTest.java
+++ b/tests/tests/carrierapi/src/android/carrierapi/cts/BaseCarrierApiTest.java
@@ -16,6 +16,8 @@
package android.carrierapi.cts;
+import static com.android.compatibility.common.util.UiccUtil.UiccCertificate.CTS_UICC_LEGACY;
+
import static com.google.common.truth.Truth.assertWithMessage;
import static org.junit.Assume.assumeTrue;
@@ -26,6 +28,7 @@
import androidx.test.InstrumentationRegistry;
import com.android.compatibility.common.util.FeatureUtil;
+import com.android.compatibility.common.util.UiccUtil;
import org.junit.Before;
@@ -45,6 +48,18 @@
protected static final String NO_CARRIER_PRIVILEGES_FAILURE_MESSAGE =
"This test requires a SIM card with carrier privilege rules on it.\n"
+ "Visit https://source.android.com/devices/tech/config/uicc.html";
+ // More specific message when the test suite detects an outdated legacy SIM.
+ private static final String DEPRECATED_TEST_SIM_FAILURE_MESSAGE =
+ "This test requires a 2021-compliant SIM card with carrier privilege rules on it.\n"
+ + "The current SIM card appears to be outdated and is not compliant with the 2021"
+ + " CTS SIM specification published with Android 12 (\"S\").\n"
+ + "As of Android 13 (\"T\"), you must use a 2021-compliant SIM card to pass this"
+ + " suite. The 2021-compliant SIM is backward compatible with the legacy"
+ + " specification, so it may also be used to run this suite on older Android"
+ + " releases.\n"
+ + "2021-compliant SIMs received directly from Google have \"2021 CTS\" printed on"
+ + " them.\n"
+ + "Visit https://source.android.com/devices/tech/config/uicc#prepare_uicc";
protected Context getContext() {
return InstrumentationRegistry.getInstrumentation().getTargetContext();
@@ -74,8 +89,15 @@
+ getClass().getSimpleName()
+ " cases will be skipped",
FeatureUtil.hasTelephony());
- // We must run with carrier privileges.
- assertWithMessage(NO_CARRIER_PRIVILEGES_FAILURE_MESSAGE)
+ // We must run with carrier privileges. As of 2022, all devices must run CTS with a SIM
+ // compliant with the 2021 spec, which has a new certificate. To make results very clear, we
+ // still explicitly check for the legacy certificate, and if we don't have carrier
+ // privileges but detect the legacy cert, we tell the tester they must upgrade to pass this
+ // test suite.
+ assertWithMessage(
+ UiccUtil.uiccHasCertificate(CTS_UICC_LEGACY)
+ ? DEPRECATED_TEST_SIM_FAILURE_MESSAGE
+ : NO_CARRIER_PRIVILEGES_FAILURE_MESSAGE)
.that(getContext().getSystemService(TelephonyManager.class).hasCarrierPrivileges())
.isTrue();
mPreconditionsSatisfied = true;